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? -- View this message in context: http://r.789695.n4.nabble.com/How-to-delete-a-date-frame-from-a-data-frame-tp2290577p2290577.html Sent from the R help mailing list archive at Nabble.com.
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
But "miceSample" has multiple columns... For example if nvars=4, I have 4 columns of data to delete from "combined". Specifically, I have 187 columns in "combined", and "miceSample" only has 4 columns. So the new data frame should have 183 columns. -- View this message in context: http://r.789695.n4.nabble.com/How-to-delete-a-date-frame-from-a-data-frame-tp2290577p2290605.html Sent from the R help mailing list archive at Nabble.com.