[R] Introduction of NA:s

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Oct 2 14:52:33 CEST 2002

Patrik Waldmann 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?

is.na(MyData[sample(outer(10 * 0:999, 6:10, "+"), 500)]) <- TRUE

Uwe Ligges
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