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. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.