[R] vector of NA indices

Friedrich Leisch Friedrich.Leisch at ci.tuwien.ac.at
Wed Jul 14 17:21:12 CEST 1999


>>>>> On Wed, 14 Jul 1999 04:09:21,
>>>>> Peter B Mandeville (PBM) wrote:

PBM> I have a vector Pes with 600 elements some of which are NA's. How can I
PBM> form a vector of the indices of the NA's.

PBM> 	for(i in 1:600) if(is.na(Pes[i])) print(i)

PBM> prints the indices of the NA's but I can't figure out how to put the
PBM> results in a vector.

try this:

x <- (1:length(Pes))[is.na(Pes)]


.fritz

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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