Summarize statistics by Groups in R & R Commander
This article is originally published at https://ekonometrics.blogspot.com/
R is great at accomplishing complex tasks. Doing simple things with R though takes some effort. Consider the simple task of producing summary statistics for continuous variables over some factor variables. Using Stata, I’d write a brief one-liner to get the mean for one or more variables using another variable as a factor. For instance, tabstat Horsepower RPM, by(Type) in Stata produces the following:
The doBy package in R offers similar functionality and more. Of particular interest for those who teach R based statistics courses in the undergraduate programs is the doBy plugin for R Commander. The plugin was developed by Jonathan Lee and it is a great tool for teaching and for quick data analysis. To get the same output as the one listed above, I’d click on the doBy plugin to get the following dialogue box:
The dialogue box results in the following simple syntax:
summaryBy(Horsepower+RPM~Type, data=Cars93, FUN=c(mean))
You may first have to load the data set:
And the results are presented below:
Jonathan has also created GUIs for order by, sample by, and split by within the same plug-in. A must use plug-in for data scientists.
Please visit source website for post related comments.