grp | R Documentation |
Inspired by dplyr::vars()
, but converting strings to symbols and auto names all arguments
grp(...)
... |
Variables to group by. These arguments are automatically quoted and later evaluated in the context of the data frame. They support unquoting. |
named list containing quosures or symbols
fn <- rOstluft.data::f("Zch_Stampfenbachstrasse_d1_2017.csv")
data <- rOstluft::read_airmo_csv(fn)
# adding group_nest to quickly glance over the groups
groupby <- function(df, group = grp()) {
dplyr::group_by(df, !!!group) %>%
dplyr::group_nest()
}
# no grouping -> everything will be nested
groupby(data)
# use a symbol, string or an expression
groupby(data, grp(site, "unit", lubridate::year(starttime)))
# autonaming works fine with strings and symbols, but for expressions
# it probably a good idea to provide a name:
groupby(data, grp(site, year = lubridate::year(starttime)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.