You should not use the system object `c' as an index! BTW, expression() takes multiple arguments, so you can do
# OK for (c2 in expression(x$a==1, x$b==1, x$c==1)) print(x[eval(c2),]) for (c2 in expression(x$a==1, x$b==1, x$c==1)) print(subset(x, eval(c2))) # error, correctly for (c2 in expression(x$a==1, x$b==1, x$c==1)) print(subset(x,c2)) Error in r & !is.na(r) : operations are possible only for numeric or logical types In addition: Warning message: is.na() applied to non-(list or vector) in: is.na(r) On Fri, 4 Jun 2004 [EMAIL PROTECTED] wrote: > Full_Name: Martin Lenze > Version: Version 1.9.0 (2004-04-12), ISBN 3-900051-00-3 > OS: Microsoft Windows 2000 [Version 5.00.2195] SP4 > Submission from: (NULL) (82.83.167.79) > now I switched to R 1.9.0 and did get a problem with subset, see sample: > > x <- data.frame(a=as.integer(round(runif(5),0)), > b=as.integer(round(runif(5),0)),c=as.integer(round(runif(5),0))) > # correct results: > for (c in c(expression(x$a==1),expression(x$b==1), > expression(x$c==1))) print(x[eval(c),]) > # results I don't understand: > for (c in c(expression(x$a==1),expression(x$b==1), > expression(x$c==1))) print(subset(x,eval(c))) > for (c in c(expression(x$a==1),expression(x$b==1), > expression(x$c==1))) print(subset(x,c)) > > Am I doing something wrong? Using subset this way with R 1.8.0 worked fine. Not for me! I get the same wrong results as in 1.9.0 with your code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-devel