[R] Extracting diagonal matrix

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Fri Nov 21 13:53:29 CET 2008


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