Skip to content
Prev 95435 / 398500 Next

random sampling problems?

with replacement or not ?

without replacement:
data1 <- cbind(id=1:9, expand.grid(x=1:3,y=1:3))
merge(data1, sapply(data1[,c("x","y")], sample, 3), all.y=T)

why not:
data1[sample(data1$id, 3),]
-------------------------------------------------------------------
Jacques VESLOT

CNRS UMR 8090
I.B.L (2?me ?tage)
1 rue du Professeur Calmette
B.P. 245
59019 Lille Cedex

Tel : 33 (0)3.20.87.10.44
Fax : 33 (0)3.20.87.10.31

http://www-good.ibl.fr
-------------------------------------------------------------------


zhijie zhang a ?crit :