Re: [R] Matrix diagonal help

2010-04-23 Thread David Winsemius
On Apr 23, 2010, at 2:30 PM, Dimitri Liakhovitski wrote: Your question is unclear. Maybe not. > mtx <- matrix(1:16, 4) > nmtx <- matrix(0, 4,4) > nmtx[1:4,1] <- mtx[row(mtx)==col(mtx)] > nmtx[1:3,2] <- mtx[row(mtx)==col(mtx)-1] > nmtx[1:2,3] <- mtx[row(mtx)==col(mtx)-2] > nmtx[1:1,4] <-

Re: [R] Matrix diagonal help

2010-04-23 Thread Dimitri Liakhovitski
Your question is unclear. On Fri, Apr 23, 2010 at 5:45 AM, Usman Munir wrote: > Hi > > Suppose I have a matrix (cohort are rows and years are columns) > > > > [2000]  [2001]  [2002]  [2003] > > [C1]     0.01     0.03     0.02     0.09 > > [C2]     0.06     0.05     0.07     0.11 > > [C3]     0.1

[R] Matrix diagonal help

2010-04-23 Thread Usman Munir
Hi Suppose I have a matrix (cohort are rows and years are columns) [2000] [2001] [2002] [2003] [C1] 0.01 0.03 0.02 0.09 [C2] 0.06 0.05 0.07 0.11 [C3] 0.1 0.5 0.4 0.98 [C4] 0.7 0.6 0.2 0.77 I want to extracts