Re: [R] Generating a sequence of diagonal matrices

2011-08-30 Thread Joshua Wiley
Hi Meddee, Try this: dmat <- lapply(1:100, function(d) diag(d, 2)) That will give you a list of all 100 matrices. Cheers, Josh On Tue, Aug 30, 2011 at 1:00 PM, meddee wrote: > I am trying to generate a sequence of diagonal matrices. > > In the scalar case I would use something like, seq(0,10

[R] Generating a sequence of diagonal matrices

2011-08-30 Thread meddee
I am trying to generate a sequence of diagonal matrices. In the scalar case I would use something like, seq(0,100,by=1). How do I generalise the above for , say a 2 dimensional diagonal matrix. In other words how do I produce the series of diagonal matrices { diag(0,2),diag(1,2), diag(2,2),...,di