I am trying to read the following file into R variables:
5060803636482931868 83.3366666 0.0 0.0 0.0
15695800775901642752 0.0 81.0061726043 38.1837661841 0.0
12047011437325700351 0.0 38.1837661841 22.2036033112 7.07106781187
2610937148294873212 0.0 0.0 7.07106781187 30.1330383466
The first column are unique keys and the rest is a 4x4 matrix;
I try reading with the following:
fileContents <- as.matrix(read.table('./distanceMatrix.txt', header=FALSE, sep = "\t",strip.white=TRUE))
nameKey <- fileContents[,1]
distMatrix <- fileContents[,-1]
I get this result:
> nameKey
[1] 5060803636482931712 15695800775901642752 12047011437325701120 2610937148294873088
> distMatrix
V2 V3 V4 V5
[1,] 83.33667 0.00000 0.000000 0.000000
[2,] 0.00000 81.00617 38.183766 0.000000
[3,] 0.00000 38.18377 22.203603 7.071068
[4,] 0.00000 0.00000 7.071068 30.133038
notice how the keys don't match the file. I need to be sure everything gets read in properly and make sure I can write it out properly. What am I doing wrong?
why not:
How is this a bioinformatics question?