Re: [R] r equivalent of egen? Not tapply

From: Tobias Muhlhofer <>
Date: Sun 26 Jun 2005 - 20:33:05 EST


I usually use the aggregate() function, proceeding as follows.

Construct a vector of 1s that is the same length as your entire data.

Then use aggregate() with sum as a function on this vector and your grouping variable as a by argument (note the use of na.rm in sum). This will create a data.frame with the counts and the panel markers that represent the subcategories (one row for each).

Then use merge() to put these back into your original data.frame, as this will create the necessary duplicates.

Toby mailing list PLEASE do read the posting guide! Received on Sun Jun 26 21:47:36 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:02 EST