[R] subset question
Hi, I'm having a problem with a step that should be pretty simple. I have a dataframe, d, with column names : gene s1 s2 s3. The column gene stores an Id; the rest of the columns store intensity data. I would like to extract the rows for gene Ids i1, i2, i3 ( I know a priori that those rows exist). So I do this: subset(d, gene %in% c(i1, i2, i3)). This does not give me the required data. Any ideas where I am going wrong? TIA, Anjan -- === anjan purkayastha, phd. research associate fas center for systems biology, harvard university 52 oxford street cambridge ma 02138 phone-703.740.6939 === [[alternative HTML version deleted]] __ 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.
Re: [R] subset question
Try subd - d[, gene == c(i1,i2,i3)] On Wed, Dec 29, 2010 at 4:55 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com wrote: Hi, I'm having a problem with a step that should be pretty simple. I have a dataframe, d, with column names : gene s1 s2 s3. The column gene stores an Id; the rest of the columns store intensity data. I would like to extract the rows for gene Ids i1, i2, i3 ( I know a priori that those rows exist). So I do this: subset(d, gene %in% c(i1, i2, i3)). This does not give me the required data. Any ideas where I am going wrong? TIA, Anjan -- === anjan purkayastha, phd. research associate fas center for systems biology, harvard university 52 oxford street cambridge ma 02138 phone-703.740.6939 === [[alternative HTML version deleted]] __ 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. [[alternative HTML version deleted]] __ 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.
Re: [R] subset question
nope, that did not work. thanks though. Anjan On Wed, Dec 29, 2010 at 5:02 PM, Jonathan Flowers jonathanmflow...@gmail.com wrote: Try subd - d[, gene == c(i1,i2,i3)] On Wed, Dec 29, 2010 at 4:55 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com wrote: Hi, I'm having a problem with a step that should be pretty simple. I have a dataframe, d, with column names : gene s1 s2 s3. The column gene stores an Id; the rest of the columns store intensity data. I would like to extract the rows for gene Ids i1, i2, i3 ( I know a priori that those rows exist). So I do this: subset(d, gene %in% c(i1, i2, i3)). This does not give me the required data. Any ideas where I am going wrong? TIA, Anjan -- === anjan purkayastha, phd. research associate fas center for systems biology, harvard university 52 oxford street cambridge ma 02138 phone-703.740.6939 === [[alternative HTML version deleted]] __ 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. -- === anjan purkayastha, phd. research associate fas center for systems biology, harvard university 52 oxford street cambridge ma 02138 phone-703.740.6939 === [[alternative HTML version deleted]] __ 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.
Re: [R] subset question
Hi Anjan, Try subset(d, gene %in% c(i1, i2, i3)) HTH, Jorge On Wed, Dec 29, 2010 at 4:55 PM, ANJAN PURKAYASTHA wrote: Hi, I'm having a problem with a step that should be pretty simple. I have a dataframe, d, with column names : gene s1 s2 s3. The column gene stores an Id; the rest of the columns store intensity data. I would like to extract the rows for gene Ids i1, i2, i3 ( I know a priori that those rows exist). So I do this: subset(d, gene %in% c(i1, i2, i3)). This does not give me the required data. Any ideas where I am going wrong? TIA, Anjan -- === anjan purkayastha, phd. research associate fas center for systems biology, harvard university 52 oxford street cambridge ma 02138 phone-703.740.6939 === [[alternative HTML version deleted]] __ 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. [[alternative HTML version deleted]] __ 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.
Re: [R] subset question
Details of *what* didn't work would be helpful, like for example error messages. Regardless, I'd do it like this: subd - d[, d$gene %in% c(i1,i2,i3), ] d gene 1 2 3 1 i1 1 6 11 2 i5 2 7 12 3 i2 3 8 13 4 i3 4 9 14 5 i1 5 10 15 d[d$gene %in% c(i1,i2,i3), ] gene 1 2 3 1 i1 1 6 11 3 i2 3 8 13 4 i3 4 9 14 5 i1 5 10 15 Sarah On Wed, Dec 29, 2010 at 5:29 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com wrote: nope, that did not work. thanks though.1 Anjan On Wed, Dec 29, 2010 at 5:02 PM, Jonathan Flowers jonathanmflow...@gmail.com wrote: Try subd - d[, gene == c(i1,i2,i3)] On Wed, Dec 29, 2010 at 4:55 PM, ANJAN PURKAYASTHA anjan.purkayas...@gmail.com wrote: Hi, I'm having a problem with a step that should be pretty simple. I have a dataframe, d, with column names : gene s1 s2 s3. The column gene stores an Id; the rest of the columns store intensity data. I would like to extract the rows for gene Ids i1, i2, i3 ( I know a priori that those rows exist). So I do this: subset(d, gene %in% c(i1, i2, i3)). This does not give me the required data. Any ideas where I am going wrong? TIA, Anjan -- 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.
Re: [R] Subset Question
Chertudi wrote: Hello helpful R folks, First off, please forgive my English. Second, I'm new with R, I've searched the archives about subsets, and I haven't found quite the help I need. I'm currently analysing a population survey whose data set has about 15000 households (the rows/observations) and 130 variables (the columns). I've managed to import the set into R as a data.frame called eu08. Now, I'm trying to look at all of the variables, but limited to one province in the region variable. I think the provinces are factors, and the province of interest is labeled '3'. I've tried the following: region3=subset(eu08, region==3) --this simply strips all of the rows from the columns, and I know that about 4000 of the observations are specific to region 3. So does putting the 3 as '3' and 3. Any help would be greatly appreciate. Well, we don't know if it really is a factor. You can determine that by doing... class(eu08$region) If it is a factor, then levels(eu08$region) should let you know what you can subset with. str(eu08) might also be good to look at... Erik __ 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.
Re: [R] Subset Question
Thank you Eric and Petr. It seems to be working now! -- View this message in context: http://n4.nabble.com/Subset-Question-tp1568555p1569464.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Subset Question
Thank you Eric and Petr. It seems to be working now! -- View this message in context: http://n4.nabble.com/Subset-Question-tp1568555p1569461.html Sent from the R help mailing list archive at Nabble.com. __ 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.
[R] Subset Question
Hello helpful R folks, First off, please forgive my English. Second, I'm new with R, I've searched the archives about subsets, and I haven't found quite the help I need. I'm currently analysing a population survey whose data set has about 15000 households (the rows/observations) and 130 variables (the columns). I've managed to import the set into R as a data.frame called eu08. Now, I'm trying to look at all of the variables, but limited to one province in the region variable. I think the provinces are factors, and the province of interest is labeled '3'. I've tried the following: region3=subset(eu08, region==3) --this simply strips all of the rows from the columns, and I know that about 4000 of the observations are specific to region 3. So does putting the 3 as '3' and 3. Any help would be greatly appreciate. -- View this message in context: http://n4.nabble.com/Subset-Question-tp1568555p1568555.html Sent from the R help mailing list archive at Nabble.com. __ 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.