aggregate

R Is Not So Hard! A Tutorial, Part 10: Creating Summary tables with aggregate()

January 21st, 2014 by

In Part 10, let’s look at the aggregate command for creating summary tables using R.

You may have a complex data set that includes categorical variables of several levels, and you may wish to create summary tables for each level of the categorical variable.

For example, your data set may include the variable Gender, a two-level categorical variable with levels Male and Female. Your data set may include other categorical variables such as Ethnicity, Hair Colour, the Treatments received by patients in a medical study, or the number of cylinders in motor vehicles.

In any case, you may wish to produce summary statistics for each level of the categorical variable. This is where the aggregate command is so helpful. (more…)