Re: [R] split dataframe by sample()

2011-06-23 Thread Sarah Goslee
It's very simple to do this in steps: > # to make separate dataframes > df <- data.frame(A=1:5, B=11:15) > df.sample <- c(1,3,4) > df[df.sample, ] A B 1 1 11 3 3 13 4 4 14 > df[-df.sample, ] A B 2 2 12 5 5 15 > > # or a list with two components > split(df, 1:nrow(df) %in% df.sample) $`FALSE`

[R] split dataframe by sample()

2011-06-23 Thread Paul Tanger
Hi, I seemingly have a simple problem, but I've spend hours reading guides & posts on this forum and I can't seem to piece together what I need. I have a dataframe where I want to divide it into two subsets: a sample, and the remainder of the dataframe in a new frame. I've tried this: split(df, s