[R] Selecting cases from a data frame
Andrew Perrin
andrew_perrin at unc.edu
Tue Mar 19 21:31:11 CET 2002
My apologies if this is obvious - I assume it is but still can't seem to
make it work.
I've got a data frame acps.df; I want to run an analysis on a subset of
that data frame, defined as the subset for which the value of OGMCAT (a
column in the data frame) is anything OTHER than 9, 11, or 12. So I'd
like to define a new data frame that consists of the same variables as in
acps.df, but without those cases. I tried this:
> acps.nopg.df<-acps.df[(acps.df$OGMCAT != 9) & (acps.df$OGMCAT != 11) &
(acps.df$OGMCAT != 12)]
but got this:
Error in "[.data.frame"(acps.df, (acps.df$OGMCAT != 9) & (acps.df$OGMCAT
!= :
undefined columns selected
Thanks for any advice.
----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin at unc.edu - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list