I have a matrix with the lower triangle filled and want to fill the upper triangle of the matrix with the lower triangle's matching values.
The code I have been trying is :
    r <-  read.table("rcorrected.csv", header = TRUE, sep = ",", check.names = FALSE)
    m <- as.matrix(r)
m[upper.tri(m, diag = FALSE)] <- m[lower.tri(m, diag= FALSE)]
Output:
Warning message:
In m[upper.tri(m, diag = FALSE)] <- m[lower.tri(m, diag = FALSE)] :
  number of items to replace is not a multiple of replacement length
    structure(m)
            1    2    3    4    5    6    7    8    9   10   11   12
 [1,]  1 1.00   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 [2,]  2 0.50 1.00   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 [3,]  3 0.57 0.50 1.00   NA   NA   NA   NA   NA   NA   NA   NA   NA
 [4,]  4 0.00 0.04 0.16 1.00   NA   NA   NA   NA   NA   NA   NA   NA
dput(head(m[, c(2,1)]))
    structure(c(1, 0.5, 0.57, 0, 0, 0.23, 1, 2, 3, 4, 5, 6), .Dim = c(6L, 
    2L), .Dimnames = list(NULL, c("1", "")))
Is the matrix m, being read as a list?
 
     
    