Hello,

Please read the posting guide: to draw samples from what? A vector? Matrix? Etc...

Anyway, here it goes. In all cases the result is a list with 4 elements.

# Draw 4 samples of integers from 1 to 10
x <- rep(10, 4)

# without replacement
set.seed(1)
lapply(x, sample, size=6)

# with replacement
set.seed(12)
lapply(x, sample, size=6, replace=TRUE)

#

# Draw 4 samples from a vector
# Make up a vector
set.seed(123)
(y <- sample(LETTERS, 10))
lapply(1:4, function(i) sample(y, size=6, replace=TRUE))


Hope this helps,

Rui Barradas

Em 18-06-2012 10:38, solafah bh escreveu:
Hello
I have a loop to draw few samples and I want to but this samples in one list, 
how I can make this? when I use it , the list show just the last sample. I want 
to know the correct way to put all samples in one list.

Regards
Sulafah
        [[alternative HTML version deleted]]



______________________________________________
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.


______________________________________________
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.

Reply via email to