I have a dataframe and I would like to count the number of rows within each group. I reguarly use the aggregate function to sum data as follows:
aggregate
The simple option to use with aggregate is the length function which will give you the length of the vector in the subset. Sometimes a little more robust is to use function(x) sum( !is.na(x) ).
length
function(x) sum( !is.na(x) )