[R] vector of NA indices
Ben Bolker
ben at eno.princeton.edu
Wed Jul 14 17:34:41 CEST 1999
On Wed, 14 Jul 1999, Peter B. Mandeville wrote:
> I have a vector Pes with 600 elements some of which are NA's. How can I
> form a vector of the indices of the NA's.
>
> for(i in 1:600) if(is.na(Pes[i])) print(i)
>
> prints the indices of the NA's but I can't figure out how to put the
> results in a vector.
>
> Thank you very much.
>
> Peter B.
x <- 1:100
> x[round(runif(20)*100)] <- NA
> (1:length(x))[is.na(x)]
[1] 1 2 3 17 23 24 31 54 58 64 70 76 84 85 92 96
(or in your case,
(1:600)[is.na(Pes)]
)
Benjamin Bolker Dep't of Ecology and Evolutionary Biology,
ben at eno.princeton.edu Princeton University
tel: (609) 258-6886, fax: (609) 258-1334
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list