[R] reading a "sparse" matrix into R

Aaron J. Mackey amackey at pcbi.upenn.edu
Tue Apr 27 23:10:09 CEST 2004


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.

node	connections
A		B	C	D	E
B		A	C	D
C		A	E
D		A
E		A	F
F		E
G
H

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.

Thanks,

-Aaron




More information about the R-help mailing list