counting unique factors in r
You could also run unique
on the data first:
aggregate(dam ~ bdate, data=unique(mydf[c("dam","date")]), FUN=length)
Then you could also use table
instead of aggregate
, though the output is a little different.
> table(unique(mydf[c("dam","date")])$bdate)
2009-10-01 2009-10-03
2 2
What about:
aggregate(dam ~ bdate, data=mydf, FUN=function(x) length(unique(x)))