Then: Set1.names <- c("MA1B1Cy5", "MA5B4Cy5") Set1.data <- mydata[mydata$ID %in% Set1.names, ]
On Wed, Jun 13, 2012 at 12:15 PM, Joshua Budman <josh.bud...@gmail.com> wrote: > This is a sample of the data: > ID chrom loc.start loc.end > 1 MA1B1Cy5 chr1 197008581 197026781 > 18 MA1B3Cy5 chr1 197079541 197080381 > 55 MA5B2Cy5 chr1 197088651 197118071 > 70 MA5B2Cy5 chr1 197172341 197189641 > 72 MA5B3Cy5 chr1 197008581 197010601 > 89 MA5B4Cy5 chr1 197025421 197025701 > 104 MA5B4Cy5 chr1 197145601 197159111 > > And I would like to put the rows which have, for instance, the "ID" MA1B1Cy5 > and MA5B4Cy5 in one data frame and then the rest of the rows in another data > frame. My decision is based on whether these samples are "tumor" or > "non-tumor" samples which I determine manually based on another document. I > hope this helps and thank you in advance! > > On 13-Jun-12, at 12:02 PM, Sarah Goslee wrote: > > How are you deciding which values in the first column go into which subset? > > If you have a vector containing those values, you could use %in% or if > they're determined logically you could use that criterion. > > A reproducible example and a bit more information would get you more > concrete answers. > > Sarah > > On Wed, Jun 13, 2012 at 11:06 AM, Joshua Budman <josh.bud...@gmail.com> > wrote: > > Hi > > I have a large data frame of the form: > > a 1 > > b 2 > > c 3 > > And I would like to split this data frame into two separate data > > frames based on the values in the first column, e.g. > > a 1 > > b 2 > > and > > c 3 > > > Is there any way of doing this without having to write a different > > "which" statement for each value in column 1 and then doing an "rbind" > > at the end? I tried using an if/else statement using a lot of > > "||" but that did not work well either. Help would be much appreciated. > > > Thanks, > > Josh > > -- Sarah Goslee http://www.functionaldiversity.org ______________________________________________ R-help@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.