[R] Extracting diagonal matrix

A Ezhil ezhil02 at yahoo.com
Fri Nov 21 16:05:38 CET 2008


Thanks. I would like to extract all the matrix entries below or above the diagnol. diag(x) simply gives diagonal elements.

Thanks.

Kind regards,
Ezhil

--- On Fri, 11/21/08, Peter Dalgaard <P.Dalgaard at biostat.ku.dk> wrote:

> From: Peter Dalgaard <P.Dalgaard at biostat.ku.dk>
> Subject: Re: [R] Extracting diagonal matrix
> To: Rory.WINSTON at rbs.com
> Cc: ezhil02 at yahoo.com, r-help at r-project.org
> Date: Friday, November 21, 2008, 6:23 PM
> Rory.WINSTON at rbs.com wrote:
> > Try
> > 
> > ?diag
> 
> 
> Or, if he really means the diagonal of a 100x100
> correlation matrix,
> 
> rep(1,100)
> 
> :-)
> 
> 
> > 
> > Rory Winston
> > RBS Global Banking & Markets
> > Office: +44 20 7085 4476
> > 
> > -----Original Message-----
> > From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of A Ezhil
> > Sent: 21 November 2008 12:28
> > To: r-help at 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 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
> 
> 
> -- 
>    O__  ---- Peter Dalgaard             Øster Farimagsgade
> 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics     PO Box 2099,
> 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark     
> Ph:  (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX:
> (+45) 35327907






More information about the R-help mailing list