[R] Equivalent to a BY command in SAS

Duncan Murdoch murdoch at stats.uwo.ca
Mon Apr 14 14:13:48 CEST 2008


On 4/14/2008 7:30 AM, zerfetzen wrote:
> Thanks all.  I will try to use both tapply and by, and have no idea how I
> missed the by function.  Thanks again.

One problem with both of those arises if you are subsetting on several 
columns.  They will do the calculations for all combinations of all 
columns, even if only a few combinations of levels are present in your 
dataset.  This can make the calculation take up a large amount of memory.

I wrote the sparseby function to handle this case; it is in the reshape 
package.

Duncan Murdoch



More information about the R-help mailing list