Sparse Matrix zu einem Datenrahmen in R
Ich habe eine spärliche Matrix
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
..@ i : int [1:37674] 1836 2297 108 472 1735 1899 2129 2131 5 67 ...
..@ p : int [1:3417] 0 2 8 22 25 35 44 45 45 47 ...
..@ Dim : int [1:2] 3416 3416
..@ Dimnames:List of 2
.. ..$ : chr [1:3416] "AAA" "AAE" "AAL" "AAN" ...
.. ..$ : chr [1:3416] "AAA" "AAE" "AAL" "AAN" ...
..@ x : num [1:37674] 1 1 1 1 1 1 1 1 1 1 ...
..@ factors : list()
Was ist eine schnelle Möglichkeit, diese Matrix in eine Liste als (mit Ausnahme von a) zu konvertieren?for loop
):
Origin Destination Weight
AAA AAE 4
AAL AAN 5
Hinweis: Ich muss nur den Ursprung und das Ziel für Gewicht> 0 abrufen