1

My data "gaa" is huge distance matrix data. The problem is I lost my origin data...So.. I want to get data.frame from distance matrix. For example,

b=data.matrix(gaa[1:5,1:5])
>b
            12         21         23         34        45
21          0          0          0          0          0
23         243         0          0          0          0
34         126        134         0          0          0
45         141        470        265         0          0
56         93         213        143        214         0

and I want data like

>orgin_gaa[1:5,]
12     xxx
21     xxx
23     xxx
34     xxx
45     xxx
56     xxx

please help me, how can I get my new data frame data? Is it impossible? Thanks for help!

김태환
  • 21
  • 3
  • Please try making this a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), it will make it much easier to address your question. – cimentadaj Dec 12 '19 at 09:21
  • 2
    Calculation of distances is an operation that reduces information. You cannot recreate your original data from the distances alone. – Roland Dec 12 '19 at 09:24
  • t <- matrix(1:9, nrow = 3, dimnames = list(c("X","Y","Z"), c("A","B","C"))) reshape2::melt(t, value.var=c("A", "B", "C")) – Dr. Flow Dec 12 '19 at 10:05
  • I'd just use `broom::tidy(dist_object)` where `dist_object <- dist(???)` and not a result from an `as.matrix` or even `data.matrix`. – Mossa Dec 12 '19 at 13:45

0 Answers0