Re: [R] Equivalent to a BY command in SAS

From: Duncan Murdoch <>
Date: Mon, 14 Apr 2008 08:13:48 -0400

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 mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon 14 Apr 2008 - 14:11:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Apr 2008 - 14:30:29 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive