Re: [R] sampling rows from a list

2012-04-02 Thread Justin Haynes
## recreating your data mydata<-list(matrix(1:9, nrow=3, byrow=T), matrix(10:15, nrow=2, byrow=T), matrix(16:30, nrow=5, byrow=T)) ## get the shortest matrix in your list n <- min(unlist(lapply(mydata, nrow))) ## subset the list into random samples of length n

Re: [R] sampling rows from a list

2012-04-02 Thread Bert Gunter
?? Something like: lapply(mydata, function(x){ nr <- nrow(x) x[sample(seq_len(nr),nr,rep=TRUE),] }) maybe. The idea is to use the sampled rows as your row index. -- Bert On Mon, Apr 2, 2012 at 11:24 AM, Bcampbell99 wrote: > Hi: > > I'm sure this seems like a rudimentary question, but I am n