To aggregate data in R, we use the aggregate()
function. This function has the following essential parameters, in this order:
x
—the data frame to aggregate.by
—a list of the factors to group by.FUN
—an aggregate function to compute the summary statistics for each group (e.g.,mean
,max
,min
,count
,sum
).
Leave a Reply