[R] random sampling or random replacement
Girish A.R.
garamach at gmail.com
Thu Jun 25 12:38:38 CEST 2009
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.
More information about the R-help
mailing list