Alex99 wrote: > Hi everyone, > > I have a dataset(named "Mydata") which includes 4 different variables named; > s1,s2,s3,s4 .Each variable(symptom) has 14 patients. > I need to use random sampling to make, 5 different samples from my data with > 5 patients in each sample. i.e. using all 4 variables I need to make 5 > different samples by changing patients(with 5 patients in each sample). > > > X8 X9 X10 X102 X110 X177 X283 X284 X286 X292 X297 X306 X308 X314 > s1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 > s2 0 0 0 0 1 0 0 0 0 0 0 0 1 0 > s3 0 1 0 0 0 0 0 0 0 0 0 0 1 0 > s4 1 0 0 0 1 0 0 0 0 1 0 0 0 0 > > > I used this code: > > temp=list(NULL) > for(i in 1:5) {temp[i]<-sample(Mydata,5, replace=F)} show(temp) > > but I get the following error: > "number of items to replace is not a multiple of replacement length" > > any idea why I get this eeror message and how can I fix it? > Thanks a lot. > > The direct cause is that you are not using temp[[i]]<-, but I don't think that sample() construct does what I think you think it does either. You might want to use replicate() instead, as in replicate(2,airquality[sample(1:153,5, replace=F),], simplify=F)
-- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ 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.