How to Use aggregate Function in R
In this article, we will discuss how to use aggregate function in R Programming Language.
aggregate() function is used to get the summary statistics of the data by group. The statistics include mean, min, sum. max etc.
aggregate(dataframe$aggregate_column, list(dataframe$group_column), FUN)
- dataframe is the input dataframe.
- aggregate_column is the column to be aggregated in the dataframe.
- group_column is the column to be grouped with FUN.
- FUN represents sum/mean/min/ max.
Example 1: R program to create with 4 columns and group with subjects and get the aggregates like minimum, sum, and maximum.
Example 2: R program to create with 4 columns and group with subjects and get the average (mean).