'Making a matrix dist without calculating distance

I have two matrices that I'm trying to run a mantel test on. To do this, they need to be in a distance format. But, I don't want R to actually calculate the distances because the data was already given to me like that.

Here's the data for one of the matrices:

structure(list(x1 = c(0, -0.1088, -0.0596, 0.016, -0.1421, -0.0695
), x10 = c(-0.1088, 0, -0.3956, -0.033, -0.2131, 0.8684), x11 = c(-0.0596, 
-0.3956, 0, -0.2305, -0.1318, -0.3511), x12 = c(0.016, -0.033, 
-0.2305, 0, 0.1366, 0.0713), x13 = c(-0.1421, -0.2131, -0.1318, 
0.1366, 0, -0.3475), x14 = c(-0.0695, 0.8684, -0.3511, 0.0713, 
-0.3475, 0), x15 = c(-0.0292, -0.0423, 0.0078, 0.1942, -0.1282, 
0.0217), x16 = c(-0.1414, -0.04, -0.2897, -0.0763, 0.0065, 0.0065
), x17 = c(-0.2187, -0.3763, 0.1088, -0.2325, 0.1434, 0.1434), 
    x19 = c(-0.3659, -0.0448, -0.0111, -0.2102, 0.3083, 0.3083
    ), x2 = c(-0.0741, 0.1489, 0.0561, -0.2504, -0.1897, 0.1086
    ), x20 = c(-0.1116, 0.0769, 0.2165, -0.3238, -0.4169, -0.4169
    ), x21 = c(-0.0414, -0.3102, 0.0743, -0.0188, 0.1548, 0.1548
    ), x4 = c(0.063, -0.2877, 0.1761, -0.2661, -0.2474, -0.2404
    ), x6 = c(-0.2049, 0.4101, -0.1072, 0.1416, -0.0072, 0.3065
    ), x7 = c(0.1261, -0.0432, 0.1472, -0.0896, -0.5046, -0.0523
    ), x8 = c(-0.3185, 0.2082, 0.1287, -0.3091, 0.1521, -0.0381
    ), x9 = c(0.0288, -0.1159, 0.063, -0.2431, -0.4076, 0.1407
    )), row.names = c(NA, -6L), class = c("tbl_df", "tbl", "data.frame"
), na.action = structure(19:25, .Names = c("19", "20", "21", 
"22", "23", "24", "25"), class = "omit"))

I also tried doing this:

class(geneticmatrixmantel) <- "dist"

but that created a list instead of a matrix.

Any help would be appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source