Skip to content
Back to formatted view

Raw Message

Message-ID: <CAK4FJ1A5+P=LtPQNFkckEB82uLwugkQyGC3kwKFhM6PAopnW7g@mail.gmail.com>
Date: 2012-02-17T22:25:33Z
From: ilai
Subject: Neighbour List to Matrix
In-Reply-To: <SNT130-W52DF25E8F60813DEA90BD5B6630@phx.gbl>

I think is good to know that list contain more than 600000 rows with
around 14000 nodes (participants).

?read.table may be unreliable for large matrices and with 14/600
you'll end up with many NA's. You might do better with

nbrs<- scan('nbrs.txt',skip=1,what=list('integer','integer',double(0)))
names(nbrs) <- c('c1','c2','c3')
xtabs(c3~c1+c2,nbrs,sparse=T)

# returns
4 x 9 sparse Matrix of class "dgCMatrix"
      1     2     3     4     5     6     7     8     9
1 .     0.065 0.044 .     .     .     .     .     .
3 0.071 .     .     0.016 0.011 .     .     .     .
4 .     .     0.004 .     .     .     0.004 .     0.004
5 .     .     .     0.010 .     0.011 .     0.009 0.004

Cheers