[R] reading a "sparse" matrix into R
reid_huntsinger at merck.com
Wed Apr 28 16:32:34 CEST 2004
I've used lists (generic vectors) for this, with integer storage mode. Then
I can easily manipulate them in R, they don't take too much room, and C code
to traverse them (e.g. find connected components) is fast.
Did you have a need for a data frame? That seems like it might be painful to
I read the text file with readLines.
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Aaron J. Mackey
Sent: Tuesday, April 27, 2004 5:10 PM
To: r-help at stat.math.ethz.ch
Subject: [R] reading a "sparse" matrix into R
I have a 47k x 47k adjacency matrix that is very sparse (at most 30
entries per row); my textual representation therefore is simply an
adjacency list of connections between nodes for each row, e.g.
A B C D E
B A C D
C A E
E A F
I'd like to import this into a dataframe of node/connection
(character/vector-of-characters) pairs. I've experimented with scan,
but haven't been able to coax it to work. I can also "hack" it with
strsplit() myself, but I thought there might be a more elegant way.
R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide!
More information about the R-help