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 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.