[R] generate multiple mvrnorm samples using apply-like

2011-05-07 Thread Michael Friendly
I want to generate multiple multivariate normal samples with different mean vectors and common covariance matrix. I can do this with a loop, but can't quite figure out how to do it with apply and friends. In the example below, I want values to have 3 columns: group, x, y # number of groups,

Re: [R] generate multiple mvrnorm samples using apply-like

2011-05-07 Thread Dennis Murphy
Hi: Does this work? v - lapply(1:nrow(means), function(j) mvrnorm(n, means[j, ], Sigma, empirical = TRUE)) vals - cbind(group = rep(1:nrow(means), each = n), do.call(rbind, v)) HTH, Dennis On Sat, May 7, 2011 at 3:34 PM, Michael Friendly frien...@yorku.ca wrote: I want to generate multiple