[R] Introduction of NA:s
Eric Lecoutre
lecoutre at stat.ucl.ac.be
Wed Oct 2 14:50:18 CEST 2002
You could use the following:
x <- rnorm(10000)
ind <- unlist(matrix(1:10000,byrow=T, ncol=10)[,6:10])
selection <- sample(ind, 500)
x[selection] <- NA
I am pretty sure there is a quicker way to create selection vector...
Eric
At 12:01 2/10/2002 +0200, you wrote:
>Hello,
>
>I wonder if someone could help me with the following: I have generated 10
>000 values from rnorm and now I want to randomly replace 500 of those with
>NA. The problem is that values indexed between 6-10,16-20,26-30.... only
>should be considered for replacement. Any suggestions?
>
>Patrik Waldmann
__________________________________________________
Eric Lecoutre Informaticien/Statisticien
Institut de Statistique UCL
(+32) (0)10 47 30 50
lecoutre at stat.ucl.ac.be
http://www.stat.ucl.ac.be/ISpersonnel/lecoutre
__________________________________________________
Le vrai danger, ce n'est pas quand les ordinateurs
penseront comme des hommes, c'est quand les hommes
penseront comme des ordinateurs. Sydney Harris
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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