agg_data | R Documentation |
Aggregates data
agg_data(
data,
cols = names(data),
group_by = NULL,
agg_fun = function(x) sum(x, na.rm = TRUE),
group_by2 = NULL,
env = parent.frame()
)
data |
A data.frame. |
cols |
Named character vector of column names. |
group_by |
Vector of grouping columns. |
agg_fun |
Function to use for aggregating. |
group_by2 |
Vector of grouping column names to use for delayed (post aggregation) calculation. |
env |
Environment for extra variables. |
An aggregated data.frame.
suppressPackageStartupMessages(library(tsibble))
library(tsibbledata)
agg_data(ansett, c("Passengers", count = "1"))
agg_data(ansett["Class"])
agg_data(ansett[c("Class", "Passengers")])
agg_data(ansett, "Passengers", "Class")
agg_data(ansett, "Passengers", c("Class", "Airports"))
agg_data(ansett, c(x = "Airports", y = "Passengers"), c(x = "Airports"))
agg_data(ansett, c(x = "Class", y = "1", group = "Airports"), c(x = "Class", group = "Airports"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.