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. -- Peter B. Mandeville mandevip at deimos.tc.uaslp.mx Jefe del Depto. de Inform?tica y Bioestad?stica rpe1531 at pasteur.fmed.uaslp.mx Facultad de Medicine Tel: 48 26-23-45 ext. 232 Universidad Aut?noma de San Luis Potos? Fax: 48 28-23-52 Av. V. Carranza 2405 Col. Los Filtros Apartado Postal 145 San Luis Potos?, S.L.P. 78210 M?xico -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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. which(is.na(Pes)) -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._