plyr (version 1.8.4)

summarise: Summarise a data frame.

Description

Summarise works in an analogous way to mutate, except instead of adding columns to an existing data frame, it creates a new data frame. This is particularly useful in conjunction with ddply as it makes it easy to perform group-wise summaries.

Usage

summarise(.data, ...)

Arguments

.data

the data frame to be summarised

...

further arguments of the form var = value

Examples

Run this code
# NOT RUN {
# Let's extract the number of teams and total period of time
# covered by the baseball dataframe
summarise(baseball,
 duration = max(year) - min(year),
 nteams = length(unique(team)))
# Combine with ddply to do that for each separate id
ddply(baseball, "id", summarise,
 duration = max(year) - min(year),
 nteams = length(unique(team)))
# }

Run the code above in your browser using DataCamp Workspace