Re: [R] Diagonal matrix with off diagonal elements

2007-12-24 Thread Martin Maechler
> "PD" == Peter Dalgaard <[EMAIL PROTECTED]> > on Sat, 22 Dec 2007 11:29:30 +0100 writes: PD> Chris Stubben wrote: >> Also try the odiag function in the demogR package >> >> odiag( 1:5, -1) >> [,1] [,2] [,3] [,4] [,5] [,6] >> [1,]000000

Re: [R] Diagonal matrix with off diagonal elements

2007-12-22 Thread Peter Dalgaard
Chris Stubben wrote: > Also try the odiag function in the demogR package > > odiag( 1:5, -1) > [,1] [,2] [,3] [,4] [,5] [,6] > [1,]000000 > [2,]100000 > [3,]020000 > [4,]003000 > [5,]000

Re: [R] Diagonal matrix with off diagonal elements

2007-12-21 Thread Chris Stubben
Also try the odiag function in the demogR package odiag( 1:5, -1) [,1] [,2] [,3] [,4] [,5] [,6] [1,]000000 [2,]100000 [3,]020000 [4,]003000 [5,]000400 [6,]000

Re: [R] Diagonal matrix with off diagonal elements

2007-12-21 Thread Gabor Grothendieck
On Dec 21, 2007 3:58 PM, Jonas Malmros <[EMAIL PROTECTED]> wrote: > I wonder if there is a function in R with which I can create a square > matrix with elements off main diagonal (for example one diagonal below > the main diagonal). Try this and adjust the formula for other patterns: > mm <- matr

Re: [R] Diagonal matrix with off diagonal elements

2007-12-21 Thread Domenico Vistocco
Jonas Malmros wrote: > Hi, everyone > > I wonder if there is a function in R with which I can create a square > matrix with elements off main diagonal (for example one diagonal below > the main diagonal). > > Thanks in advance! > > You could combine rbind, diag and cbind: rbind(rep(0,3),cbind(d

[R] Diagonal matrix with off diagonal elements

2007-12-21 Thread Jonas Malmros
Hi, everyone I wonder if there is a function in R with which I can create a square matrix with elements off main diagonal (for example one diagonal below the main diagonal). Thanks in advance! -- Jonas Malmros Stockholm University Stockholm, Sweden _