Thomas, 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 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html