Re: [R] Extracting diagonal matrix

2008-11-21 Thread A Ezhil
Hi, Thank you very much for the help. c[lower.tri(c,diag=FALSE)] works fine for me. Thanks again. Kind regards, Ezhil --- On Fri, 11/21/08, Anup Menon <[EMAIL PROTECTED]> wrote: > From: Anup Menon <[EMAIL PROTECTED]> > Subject: Re: [R] Extracting diagonal matrix > To: [

Re: [R] Extracting diagonal matrix

2008-11-21 Thread Anup Menon
Hi Ezhil, Maybe this will help. There might be an easier way to do this but here is one solution. tril <- function(A) { A <- as.matrix(A) cmats <- matrix(rep(1,length(A)),dim(A)[1],dim(A)[2]) upper.tri(cmats,diag=T) cmats[upper.tri(cmats)] <- 0 out <- A*cmats return(out) } tril(correlation

Re: [R] Extracting diagonal matrix

2008-11-21 Thread Stavros Macrakis
You can also do it from first principles: outer(1:100,1:100,`<`) * m which generalizes nicely to >, <=, >=, !=, etc. -s On 11/21/08, Henrique Dallazuanna <[EMAIL PROTECTED]> wrote: > See ?upper.tri and ?lower.tri. __ R-help@r-project.o

Re: [R] Extracting diagonal matrix

2008-11-21 Thread Henrique Dallazuanna
> --- On Fri, 11/21/08, Peter Dalgaard <[EMAIL PROTECTED]> wrote: > > > From: Peter Dalgaard <[EMAIL PROTECTED]> > > Subject: Re: [R] Extracting diagonal matrix > > To: [EMAIL PROTECTED] > > Cc: [EMAIL PROTECTED], r-help@r-project.org > > D

Re: [R] Extracting diagonal matrix

2008-11-21 Thread A Ezhil
elation matrix, > > rep(1,100) > > :-) > > > > > > Rory Winston > > RBS Global Banking & Markets > > Office: +44 20 7085 4476 > > > > -Original Message- > > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of

Re: [R] Extracting diagonal matrix

2008-11-21 Thread Peter Dalgaard
CTED] [mailto:[EMAIL PROTECTED] On Behalf Of A Ezhil > Sent: 21 November 2008 12:28 > To: r-help@r-project.org > Subject: [R] Extracting diagonal matrix > > Dear All, > > I have a correlation matrix of size 100 x 100 and would like to extract the > diagonal matrix from it. I

Re: [R] Extracting diagonal matrix

2008-11-21 Thread Rory.WINSTON
Try ?diag Rory Winston RBS Global Banking & Markets Office: +44 20 7085 4476 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of A Ezhil Sent: 21 November 2008 12:28 To: r-help@r-project.org Subject: [R] Extracting diagonal matrix Dear All, I ha

[R] Extracting diagonal matrix

2008-11-21 Thread A Ezhil
Dear All, I have a correlation matrix of size 100 x 100 and would like to extract the diagonal matrix from it. I have used the for loop to store tha correlation values of the diagonal matrix. Is there a 'R way' of doing this? Thanks in advance. Kind regards, Ezhil