agg_key | R Documentation |
Aggregate based on key
agg_key(
x,
by = NULL,
.fns = sum,
value_cols = c("values", "value"),
w = NULL,
na.rm = FALSE,
all_to_regions = TRUE,
key = NULL
)
x |
A data.frame like object. |
by |
A character vector of variables to join by. |
na.rm |
logical. Should missing values (including NaN) be removed? |
key |
A data.frame. A classification key in same form as
as key from |
x <- data.frame(alue_code = c("SSS", "KU049", "KU091", "KU109"), values = c(1,1,1,2))
agg_regions(x, na.rm = TRUE)
agg_regions(x, na.rm = TRUE, pass_region_codes = "SSS")
agg_regions(x, na.rm = TRUE, pass_region_codes = "SSS", all_to_regions = FALSE)
z <- dplyr::mutate(x, values2 = c(3,4,5,6))
agg_regions(z, na.rm = TRUE, value_cols = c("values", "values2"))
agg_key(x, na.rm = TRUE,
key = data.frame(
alue_code = c("SSS", "KU049", "KU091", "KU109"),
maakunta_name = c("SSS", "Maakunta1", "Maakunta1", "Maakunta2"))
)
agg_key(x,
.fns = mean,
key = data.frame(
alue_code = c("SSS", "KU049", "KU091", "KU109"),
maakunta_name = c("SSS", "Maakunta1", "Maakunta1", "Maakunta2"))
)
xx <- data.frame(alue_code = c("SSS", "KU049", "KU091", "KU109"), values = c(1,2,1,1), size = c(1,2,1,1))
agg_key(xx,
.fns = weighted.mean,
w = size,
key = data.frame(
alue_code = c("SSS", "KU049", "KU091", "KU109"),
maakunta_name = c("SSS", "Maakunta1", "Maakunta1", "Maakunta2"))
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.