[R] Group by in R

David Winsemius dwinsemius at comcast.net
Mon Apr 13 15:29:33 CEST 2009


On Apr 13, 2009, at 7:26 AM, Nick Angelou wrote:

>
> Thanks a lot, guys. Gabor's and Mike's suggestion worked. Duncan's  
> did not do
> exactly what I expected (I guess it's the "paste" in Mike's that makes
> "table" work as I needed it).
>
> One more question - is there a convenient way to order the group by  
> results
> as follows:
>
> As rows: the unique combinations of factors f1, f2, f3, as columns the
> unique values of f4. The counts are basically the same as of the  
> GROUP BY
> statement (or the paste and table combination suggested by Mike).   
> Only the
> way the result is structured is different.

Tables are actually specific instances of matrices, so if you want to  
transpose the default arrangement of columns and rows in a table named  
tab1, try:

?t
t(tab1)

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list