Tobias, I'm not sure if this is what you're after, but perhaps it will help.
# create a list of 5 vectors n <- 5 subsets <- lapply(1:n, function(x) rnorm(5, mean=80, sd=1)) # create another list that takes 2 bootstrap samples from each of the 5 vectors and puts them in a matrix nbootstrap <- 2 test <- lapply(subsets, function(x) matrix(sample(x, nbootstrap*length(x), replace=TRUE), ncol=nbootstrap)) subsets test Jean On Wed, Apr 17, 2013 at 1:09 PM, Berg, Tobias van den <to.vandenb...@vumc.nl > wrote: > Dear R experts, > > I am trying to simulate a list containing data matrices. Unfortunately, I > don't manage to get it to work. > > A small example: > > n=5 > nbootstrap=2 > > subsets<-list() > for (i in 1:n){ > subsets[[i]] <- rnorm(5, mean=80, sd=1) > > > for (j in 1:nbootstrap){ > test<-list() > test[[j]]<-subsets[[i]] > } > } > > How can I get test to be 2 simulation rounds with each 5 matrices. > > Kind regards, Tobias > > > > [[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. > [[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.