Skip to content
Back to formatted view

Raw Message

Message-ID: <4A159D6A.5070308@gmail.com>
Date: 2009-05-21T18:28:58Z
From: Szilard
Subject: NA when indexing vectors

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