tags:

views:

69

answers:

2

I have data that looks like this:

                   model                aspect cover contour
1                        flowering ~ 1      2    52    2400
2   flowering ~ 1 + temp + precip:temp      1    52    2390
3        flowering ~ 1 + temp + precip      1    52    2390
4        flowering ~ 1 + temp + precip      1    52    2390
5 flowering ~ 1 + precip + precip:temp      1    52    2400
6 flowering ~ 1 + precip + precip:temp      1    52    2400

There are 40,000 rows in this dataset with 54 unique models.

How do I get a summarized dataset showing how many times each model occurs in a aspect x contour x cover combination?

+1  A: 

try this (assumes your data is in a data frame called myData):

comboCount <- ddply(myData, c("model","aspect","cover","contour") function(df) nrow(df))
JD Long
+2  A: 

plyr provides an optimised function for this special case:

comboCount <- count(myData, c("model","aspect","cover","contour"))
hadley