[R] how to convert the lower triangle of a matrix to a symmetricmatrix

Olivier ETERRADOSSI olivier.eterradossi at ema.fr
Mon Apr 23 11:31:07 CEST 2007


Sorry if this answer was already given, or if I miss the point,
but did you have a look to "lowerTriangle" and "upperTriangle" functions 
in the "gdata" package ?

# example
# A<-matrix(rnorm(9),3,3)
# B<-B<-matrix(NA,dim(A)[1],dim(A)[2])
# lowerTriangle(B)<-lowerTriangle(A)
# upperTriangle(B)<-lowerTriangle(A)
# diag(B)<-diag(A)

Hope this helps, sorry if it was already answered.
Olivier

-- 
Olivier ETERRADOSSI
Maître-Assistant
CMGD / Equipe "Propriétés Psycho-Sensorielles des Matériaux"
Ecole des Mines d'Alès
Hélioparc, 2 av. P. Angot, F-64053 PAU CEDEX 9
tel std: +33 (0)5.59.30.54.25
tel direct: +33 (0)5.59.30.90.35 
fax: +33 (0)5.59.30.63.68
http://www.ema.fr



More information about the R-help mailing list