[R] re-sampling of large sacle data

Joshua Wiley jwiley.psych at gmail.com
Wed Jul 28 00:54:45 CEST 2010


It looks to me like you keep sampling from some dataset 's' 10,000
times.  Since you can sample() with replacement, I wonder if you could
just take a sample of the size you want, rather than using a loop with
sample.  Perhaps along these lines:

d <- apply(s, 2, sample, size = 10000*nrow(s), replace = TRUE)
pos_neg_tem <- t(apply(d,1,doit))

Josh

On Tue, Jul 27, 2010 at 3:44 PM, jd6688 <jdsignature at gmail.com> wrote:
>
> I am trying to do the following to accomplish the tasks, can anybody to
> simplify the solutions.
>
> Thanks,
>
> for (i in 1:10000){
>  d<-apply(s,2,sample)
>  pos_neg_tem<-t(apply(d,1,doit))
>  if (i>1){
>   pos_neg_pool<-rbind(pos_neg_pool,pos_neg_tem)
>
>  }else{
>
>  pos_neg_pool<- pos_neg_tem
> }}
> --
> View this message in context: http://r.789695.n4.nabble.com/re-sampling-of-large-sacle-data-tp2304165p2304221.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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list