Can anyone help me maybe with a question I can seem to find an answer on. I have this: x = c(1, 5, 70, 53, 7, 29, 75, 37, 30, 11) And I would like to have the numbers above 20 selected out. But I can't find what code I need for that.... I tried sort(), but then I can't fill in I only need those above 20. -- View this message in context: http://r.789695.n4.nabble.com/Sort-out-number-on-value-tp4573467p4573467.html Sent from the R help mailing list archive at Nabble.com.
Le vendredi 20 avril 2012 ? 03:26 -0700, Yellow a ?crit :> Can anyone help me maybe with a question I can seem to find an answer on. > > I have this: x = c(1, 5, 70, 53, 7, 29, 75, 37, 30, 11) > > And I would like to have the numbers above 20 selected out. > But I can't find what code I need for that.... > I tried sort(), but then I can't fill in I only need those above 20.x[x <= 20] Cheers
This really has little to do with sorting, but can be much more easily done with logical subscripting: x[x < 20] which I read as "x such that x is less than 20". Hope this helps, Michael On Fri, Apr 20, 2012 at 6:26 AM, Yellow <s1010265 at student.hsleiden.nl> wrote:> Can anyone help me maybe with a question I can seem to find an answer on. > > I have this: x = c(1, 5, 70, 53, 7, 29, 75, 37, 30, 11) > > And I would like to have the numbers above 20 selected out. > But I can't find what code I need for that.... > I tried sort(), but then I can't fill in I only need those above 20. > > -- > View this message in context: http://r.789695.n4.nabble.com/Sort-out-number-on-value-tp4573467p4573467.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.
HI, x[x>20] Regards. ----- Mail original ----- De?: Yellow <s1010265 at student.hsleiden.nl> ??: r-help at r-project.org Cc?: Envoy? le : Vendredi 20 avril 2012 19h26 Objet?: [R] Sort out number on value Can anyone help me maybe with a question I can seem to find an answer on. I have this: x = c(1, 5, 70, 53, 7, 29, 75, 37, 30, 11) And I would like to have the numbers above 20 selected out. But I can't find what code I need for that.... I tried sort(), but then I can't fill in I only need those above 20. -- View this message in context: http://r.789695.n4.nabble.com/Sort-out-number-on-value-tp4573467p4573467.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.