inkhorn
2012-Mar-29 18:37 UTC
[R] Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame
Hello, Let's say I've drawn a random sample (sample1.df) from a large data frame (main.df), and I want to create a second random sample (sample2.df) where the values in its ID column *are not* in the equivalent ID column in the first sample (sample1.df). How would I go about doing this? In other words: The values in sample2.df$ID *are not found* in sample1.df$ID, and both samples are drawn from main.df. Thanks in advance, Matt Dubins -- View this message in context: http://r.789695.n4.nabble.com/Random-sample-from-a-data-frame-where-ID-column-values-don-t-match-the-values-in-an-ID-column-in-a-se-tp4516448p4516448.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2012-Mar-29 20:00 UTC
[R] Random sample from a data frame where ID column values don't match the values in an ID column in a second data frame
On Mar 29, 2012, at 2:37 PM, inkhorn wrote:> Hello, > > Let's say I've drawn a random sample () from a large data frame > (main.df), and I want to create a second random sample (sample2.df) > where > the values in its ID column *are not* in the equivalent ID column in > the > first sample (sample1.df). How would I go about doing this? > > In other words: > > The values in sample2.df$ID *are not found* in sample1.df$ID, and > both > samples are drawn from main.df. >?"%in%" sample2.df <- main.df[ ! main.df[, "ID"] %in% sample1.df[, "ID"] , ]> Thanks in advance, > Matt Dubins > > -- > View this message in context: http://r.789695.n4.nabble.com/Random-sample-from-a-data-frame-where-ID-column-values-don-t-match-the-values-in-an-ID-column-in-a-se-tp4516448p4516448.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT
Maybe Matching Threads
- computing marginal values based on multiple columns?
- How to Store the executed values in a dataframe & rle function
- conditional filter resulting in 2 new dataframes
- phantom NA/NaN/Inf in foreign function call (or something altogether different?)
- average columns of data frame corresponding to replicates