[R] How to delete a date frame from a data frame
Marc Schwartz
marc_schwartz at me.com
Thu Jul 15 21:45:42 CEST 2010
On Jul 15, 2010, at 2:37 PM, Addi Wei wrote:
>
> e.g. I have a big data set called "combined", and then a small sample of
> "combined" called "miceSample". I wish to delete "miceSample" from
> "combined" to create a new smaller data set and store it into a new object.
>
> combined <- rbind(scaleMiceTrain, scaleMiceTest)
> miceSample <- sample(combined[,-c(1,2)],nvars, replace=FALSE)
>
> How do I do that?
See ?subset
If you have a column in your data frame, say called 'Group', that contains an indicator as to which group each record belongs to:
subset(combined, Group != "miceSample")
will return a new data frame without the records where the Group column contains 'miceSample'.
HTH,
Marc Schwartz
More information about the R-help
mailing list