[R] Introduction of NA:s
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Wed Oct 2 13:08:16 CEST 2002
"Patrik Waldmann" <patrik.waldmann at djingis.se> writes:
> 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?
x <- rnorm(10000)
x[sample(c(outer(-4:0,seq(10,10000,10),"+")),500)] <- NA
print(matrix(x,ncol=10,byrow=T),digits=1)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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