[R] Data frame to matrix - revisited
Jagz Bell
jagzbell at yahoo.com
Tue Aug 2 19:00:56 CEST 2011
Hi,
I've tried to look through all the previous related Threads/posts but can't find a solution to what's probably a simple question.
I have a data frame comprised of three columns e.g.:
ID1 ID2 Value
a b 1
b d 1
c a 2
c e 1
d a 1
e d 2
I'd like to convert the data to a matrix i.e.:
a b c d e
a n/a 1 2 1 n/a
b 1 n/a n/a 1 n/a
c 2 n/a n/a n/a 1
d 1 1 n/a n/a 2
e n/a n/a 1 2 n/a
Any help is much appreciated,
Jagz
More information about the R-help
mailing list