Joanne, ==================== [...snip...]
x <- sample(10000:20000, 100) #without replacement Now I want x to contain to 20% missing data (NA). Could anyone help me how to do this? ================ See if this helps: n <- length(x) x[sample(n, 0.2*n)] <- NA cheers, -Girish -- View this message in context: http://www.nabble.com/random-sampling-or-random-replacement-tp24199695p24200909.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.