How do I transform a single colmn list to item matrix in R?
Posted
by
Indy
on Stack Overflow
See other posts from Stack Overflow
or by Indy
Published on 2012-10-26T22:58:01Z
Indexed on
2012/10/26
23:00 UTC
Read the original article
Hit count: 143
I currently have data that is in the following format (note, this is 1 column, 4 row matrix):
aa|bb
bb|cc|ee|ee
cc
cc|ee
and I want it displayed so that the column names are: aa, bb, cc, dd, and ee. And I want there to be 4 row such that each row counts the number of times each string was present in the matching row above.
ie)
aa bb cc dd ee
1 1 0 0 0
0 1 1 0 2
0 0 1 0 0
0 0 1 0 1
Does anyone know how to do this in R? I would post my attempt, but it is just getting ugly and complicated. Any help would be much appreciated.
Thanks in advance.
© Stack Overflow or respective owner