[R] resampling
Rui Barradas
ruipbarradas at sapo.pt
Thu Aug 1 00:04:44 CEST 2013
Hello,
The best way seems to be ?replicate.
set.seed(3997) # make it reproducible
x <- rnorm(1002) # make up some data
sim <- replicate(1000, sample(x, 20))
colSds <- function(x, na.rm = FALSE) apply(x, 2, sd, na.rm = na.rm)
mu <- colMeans(sim)
sigma <- colSds(sim)
Hope this helps,
Rui Barradas
Em 31-07-2013 12:23, Rita Gamito escreveu:
> Could anyone tell me how,from a pool of 1002 observations (one variable), can I resample 1000 samples of 20 observations?
> And then calculate the mean and standard deviation between 2, 3, 4, ..., 1000 samples and plot them?
> Thank you!
>
> _____________________________________
>
> Rita Gamito
> Centro de Oceanografia
> Faculdade de Ciências, Universidade de Lisboa
> Campo Grande, 1749-016 Lisboa, Portugal
> e-mail: rgamito at fc.ul.pt
> Tel: + 351 21 750 00 00 - ext. 22575
> Fax: + 351 21 750 02 07
> www.co.fc.ul.pt
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list