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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to