Hi, m1<- matrix(NA,5,5) m1[upper.tri(m1)]<-c(2,3,8,4,9,14,5,10,15,20) One way would be: m1[lower.tri(m1)]<-t(m1)[lower.tri(t(m1))] m1 # [,1] [,2] [,3] [,4] [,5] #[1,] NA 2 3 4 5 #[2,] 2 NA 8 9 10 #[3,] 3 8 NA 14 15 #[4,] 4 9 14 NA 20 #[5,] 5 10 15 20 NA A.K.
Hello ! I would like to have some simple sintax in order to fill my matrix with its transposed. That is, as an example I have a correlation matrix like this, and the transposed one: > matrix [,1] [,2] [,3] [,4] [,5] [1,] NA 2 3 4 5 [2,] NA NA 8 9 10 [3,] NA NA NA 14 15 [4,] NA NA NA NA 20 [5,] NA NA NA NA NA > transposed.matrix<-t(matrix) [,1] [,2] [,3] [,4] [,5] [1,] NA NA NA NA NA [2,] 2 NA NA NA NA [3,] 3 8 NA NA NA [4,] 4 9 14 NA NA [5,] 5 10 15 20 NA And I would like to have.... [,1] [,2] [,3] [,4] [,5] [1,] NA 2 3 4 5 [2,] 2 NA 8 9 10 [3,] 3 8 NA 14 15 [4,] 4 9 14 NA 20 [5,] 5 10 15 20 NA Thank you very much for your help !! ______________________________________________ R-help@r-project.org 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.