[R] random sampling or random replacement
Paul Chatfield
p.s.chatfield at rdg.ac.uk
Thu Jun 25 12:23:20 CEST 2009
If you want to average 20% missing values then you could try it in 1 step,
viz:
sample(c(10000:20000, rep(NA, 2000)),100)
Otherwise, 2 steps is preferable. Use code as below:
sample(10000:20000,100)->kk
kk[sample(1:100,20)]<-NA
Paul
--
View this message in context: http://www.nabble.com/random-sampling-or-random-replacement-tp24199695p24200736.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list