I have a two-dimensional table with distances in data.frame in R (imported from csv):
CP000036 CP001063 CP001368 CP000036 0 ab CP001063 a 0 c CP001368 bc 0
I would like to smooth it out. that I have one axis value in the first column, and another axis value in the second column, and then the distance in the third column:
Genome1 Genome2 Dist CP000036 CP001063 a CP000036 CP001368 b CP001063 CP001368 c
The above is ideal, but it would be quite normal to repeat so that each cell in the input matrix has its own row:
Genome1 Genome2 Dist CP000036 CP000036 0 CP000036 CP001063 a CP000036 CP001368 b CP001063 CP000036 a CP001063 CP001063 0 CP001063 CP001368 c CP001368 CP000036 b CP001368 CP001063 c CP001368 CP001368 0
Here is an example of a 3x3 matrix, but my data set is much larger (about 2000x2000). I would do this in Excel, but I need ~ 3 million rows to output, while the maximum Excel is ~ 1 million.
This question is very similar to "How to" collapse "or" collapse "a 2D Excel spreadsheet in 1D?" 1
source share