[R] random sampling or random replacement

Joanne Demmler J.Demmler at swansea.ac.uk
Thu Jun 25 11:00:47 CEST 2009


Dear R users,

I'm trying to randomly recreate a real dataset with missing data and I'm 
not quite sure if I can use the sample command for this. I think it 
might be better to do it in 2 steps and randomly replace the sampled 
data with missing data...

So something like this

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?

Thanks
Joanne

-- 
========================================

Joanne Demmler Ph.D.
Research Assistant
School of Medicine
Swansea University
Singleton Park
Swansea SA2 8PP
UK  

tel: 		+44 (0)1792 295674
fax: 		+44 (0)1792 513430
email: 		j.demmler at swansea.ac.uk
DECIPHer:	www.decipher.uk.net




More information about the R-help mailing list