Hi, Try: which( x>=2 )
HTH, Jorge On Thu, May 21, 2009 at 2:28 PM, Szilard <szilard.mailingli...@gmail.com>wrote: > Hello: > > Is there a more natural way to get all elements that satisfy a condition > when there are NAs in the sample? > > > x=c(1,2,NA) > > > x>=2 > [1] FALSE TRUE NA > > > x[x>=2] > [1] 2 NA ## I would expect here to get just "2" > > > x[!is.na(x) & x>=2] ## seems a bit cumbersome > [1] 2 > > Thanks, > Szilard > > ______________________________________________ > 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.