[R] Rows to Column

marcos.takahashi marcos.takahashi at mobly.com.br
Sun Dec 15 23:52:16 CET 2013


Hi all,
I'm kinda new in R programming and I need some help preparing a database to
run logistic regression.

I have data in a tuple form:

*id cat val*
1   A   2
1   C   4
3   B   1
5   A   2
6   A   3
6   B   5
6   C   2
8   B   5
8   D   2
9   D   3

and would like to have it like:

*id	catA	catB	catC	catD*
1    2    0      4      0
3    0    1      0      0
5    2    0      0      0
6    3    5      2      0
8    0    5      0      2
9    0    0      0      3

Could someone help me?
I have already tried table function, but it doesn't return row and column
names.



--
View this message in context: http://r.789695.n4.nabble.com/Rows-to-Column-tp4682245.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list