[R] suggested method to transform list to a matrix
David Winsemius
dwinsemius at comcast.net
Thu Apr 19 22:38:26 CEST 2012
On Apr 19, 2012, at 1:48 PM, Tim Stutt wrote:
> I have data in the following list format:
>
> USER,VARIABLE,COUNT
> user1, var1, 3
> user1, var2, 4
> user2, var1, 7
> userN, var12, 5
>
> And would like to have it format as a matrix:
>
> var1 var2 var12
> user1 3 4
> user2 7
> userN 5
>
> What is the suggested method to do this for 1 million rows, with 12
> variables and ~ 4,000 unique users?
?xtabs
xtabs( COUNT ~ USER + VARIABLE, data=dfrm )
--
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list