I figured out something new that I would like to see if I can do this more easy with R then Excel. I have these huge files with data. For example: DataFile.csv ID Name log2 1 Fantasy 5.651 2 New 7.60518 3 Finding 8.9532 4 Looeka -0.248652 5 Vani 0.3548 With like header1: ID, header 2: Name, header 3: log2 Now I need to get the $ID out who have a &log2 value higher then 7. I know ho to grab the $log2 values with 7+ numbers. Log2HigherSeven = DataFile$log2 [ DataFile$log2 >= 7] But how can I take thise ID numbers also? -- View this message in context: http://r.789695.n4.nabble.com/How-to-take-ID-of-number-7-tp4577998p4577998.html Sent from the R help mailing list archive at Nabble.com.
On 22-04-2012, at 13:03, Yellow wrote:> I figured out something new that I would like to see if I can do this more > easy with R then Excel. > > I have these huge files with data. > For example: > > DataFile.csv > ID Name log2 > 1 Fantasy 5.651 > 2 New 7.60518 > 3 Finding 8.9532 > 4 Looeka -0.248652 > 5 Vani 0.3548 > > With like header1: ID, header 2: Name, header 3: log2 > > Now I need to get the $ID out who have a &log2 value higher then 7. > > I know ho to grab the $log2 values with 7+ numbers. > > Log2HigherSeven = DataFile$log2 [ DataFile$log2 >= 7] >How about DataFile[DataFile$log2 >= 7, c("ID","Log2")] to get a dataframe with two columns ID and log2. Berend
Hello, Berend Hasselman wrote> > On 22-04-2012, at 13:03, Yellow wrote: > >> I figured out something new that I would like to see if I can do this >> more >> easy with R then Excel. >> >> I have these huge files with data. >> For example: >> >> DataFile.csv >> ID Name log2 >> 1 Fantasy 5.651 >> 2 New 7.60518 >> 3 Finding 8.9532 >> 4 Looeka -0.248652 >> 5 Vani 0.3548 >> >> With like header1: ID, header 2: Name, header 3: log2 >> >> Now I need to get the $ID out who have a &log2 value higher then 7. >> >> I know ho to grab the $log2 values with 7+ numbers. >> >> Log2HigherSeven = DataFile$log2 [ DataFile$log2 >= 7] >> > How about > > DataFile[DataFile$log2 >= 7, c("ID","Log2")] > > to get a dataframe with two columns ID and log2. > > Berend > > ______________________________________________ > R-help@ 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. >Or maybe create an index vector into the rows of the data frame. This would be more flexible, later any columns could be extracted. The index can be a logical or integer vector. inx.log <- DataFile$log2 >= 7 inx.int <- which(DataFile$log2 >= 7) DataFile[inx.one.of.them, needed.cols] As a side effect, it might also save some memory. Both indexes are internally integers. Hope this helps, Rui Barradas -- View this message in context: http://r.789695.n4.nabble.com/How-to-take-ID-of-number-7-tp4577998p4578162.html Sent from the R help mailing list archive at Nabble.com.
On Sun, Apr 22, 2012 at 7:03 AM, Yellow <s1010265 at student.hsleiden.nl> wrote:> I figured out something new that I would like to see if I can do this more > easy with R then Excel. > > I have these huge files with data. > For example: > > DataFile.csv > ID Name log2 > 1 Fantasy 5.651 > 2 New 7.60518 > 3 Finding 8.9532 > 4 Looeka -0.248652 > 5 Vani 0.3548 > > With like header1: ID, header 2: Name, header 3: log2 > > Now I need to get the $ID out who have a &log2 value higher then 7. > > I know ho to grab the $log2 values with 7+ numbers. > > Log2HigherSeven = DataFile$log2 [ DataFile$log2 >= 7] > > But how can I take thise ID numbers also?Seems like there were already a few suggestions in this thread, but I'm surprised no one has suggested the use of `subset` yet, see ?subset: R> interesting <- subset(DataFile, log2 >= 7)$ID Now play with the `interesting` data.frame to get the data you need -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology ?| Memorial Sloan-Kettering Cancer Center ?| Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact
Thanks for the help. :) I was also looking at attach() but this one works perfect. -- View this message in context: http://r.789695.n4.nabble.com/How-to-take-ID-of-number-7-tp4577998p4579982.html Sent from the R help mailing list archive at Nabble.com.