That's golden Henrique, thanks a lot! Worked like a charm even with large datasets.
On Tue, Sep 21, 2010 at 2:56 PM, Henrique Dallazuanna <www...@gmail.com>wrote: > Try this: > > d <- data.frame(A = letters[1:10], B = sample(letters[11:20]), C = > sample(10)) > xtabs(C ~ A + B, d) > > On Tue, Sep 21, 2010 at 8:39 AM, ZeMajik <zema...@gmail.com> wrote: > >> Hey, >> >> I have a dataset where two columns are factors and another column consists >> of values. Each combination of factors can only have a single value >> assigned >> to it. >> I'd like to represent this as a matrix or table where the rows are the >> first >> column factors and the columns the second column factors. So that each >> cell >> a_ij in the matrix represents the associated value for the factor >> combination ij. >> When no such value exists for the combination the value should be 0. >> >> I've tried playing around with tables to get this to work, but I can't >> seem >> to get it right. I've also had little luck when trying to find a solution >> to >> this. >> >> Any help would be much appreciated! >> >> Mike >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >> > > > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49° 16' 22" O > [[alternative HTML version deleted]]
______________________________________________ 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.