Re: [R] generating many matrices

From: hadley wickham <>
Date: Wed, 06 Jun 2007 15:58:25 +0200

On 6/6/07, Keun-Hyung Choi <> wrote:
> I'd like to generate many matrices (let's say 100 matrices of 4x4), of which
> diagonal elements are being drawn from each set of sample of known
> distribution.
> What would be the best way? I've been trying to find any previous threads
> for this topic, but haven't been able to find one.

One approach would be:

replicate(100, diag(runif(4)), simplify=FALSE)

Hadley mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed 06 Jun 2007 - 14:15:45 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 06 Jun 2007 - 15:01:37 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.