[R] Random Relabelling

Dennis Murphy djmuser at gmail.com
Wed Apr 20 21:11:21 CEST 2011


Hi:

How about

y <- rnorm(4000)
ymat <- rowMeans(replicate(1000, y[sample(4000)]))
hist(ymeans)

system.time({y <- rnorm(4000); yy <- rowMeans(replicate(1000,
y[sample(4000)]))})
   user  system elapsed
   0.19    0.03    0.22

HTH,
Dennis

On Wed, Apr 20, 2011 at 7:04 AM, kmatthews <kevin-matthews at uiowa.edu> wrote:
> I have 4000 observations that I need to randomly relabel 1000 times and then
> calculate the mean of the 1000 values at each of the 4000 points.  Any ideas
> for where to begin?
>
> Thanks
> Kevin
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Random-Relabelling-tp3463100p3463100.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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