You can try this also: Vectorize(sample, 'size')(y, 1:3)
On Mon, Sep 13, 2010 at 12:30 PM, James Hudson <jmghud...@gmail.com> wrote: > Id like to sample the vector y repeatedly. In this dummy dataset, Id > like to sample (and store) it 1, 2, and 3 times. > > > > Is there a straightforward way to do this without using a for loop? > > > > x <- c(1 :3) > > > > y <- c(1:10) > > > > (run.sample <- sample (y, x)) > > > > > > Thanks very much, > > James Hudson > > [[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. > > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[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.