ok, I\'m trying to wrap my head around dplyr, using it instead of plyr. In my short time with R I\'ve grown somewhat accustomed to ddply. I\'m using a \"simple\" example fo
Thanks for the help. I like this answer. Not quite as compact as the original ddply command, but a heck of a lot more readable. (side note: answering a question is a pain, needs work)
t3.table <- diamonds %>% group_by(clarity, cut) %>% summarise(nrow=n())
In the latest version of dplyr you can simplify that down to this:
diamonds %>% count(clarity, cut)
Or if you want to keep the column name 'nrow':
diamonds %>% count(clarity, cut) %>% rename(nrow = n)
If you've got plyr or rename loaded in your environment then you might need to prefix the rename:
diamonds %>% count(clarity, cut) %>% dplyr::rename(nrow = n)