project_se | R Documentation |
project data by grouping, and adding aggregate columns.
project_se(source, assignments, ..., groupby = c(), env = parent.frame())
aggregate_se(source, assignments, ..., groupby = c(), env = parent.frame())
source |
source to select from. |
assignments |
new column assignment expressions. |
... |
not used, force later arguments to be by name |
groupby |
grouping columns. |
env |
environment to look for values in. |
project node.
if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) {
my_db <- DBI::dbConnect(RSQLite::SQLite(),
":memory:")
d <- rq_copy_to(
my_db, 'd',
data.frame(group = c('a', 'a', 'b', 'b'),
val = 1:4,
stringsAsFactors = FALSE))
op_tree <- d %.>%
project_se(., groupby = "group", "vmax" %:=% "max(val)")
cat(format(op_tree))
sql <- to_sql(op_tree, my_db)
cat(sql)
execute(my_db, op_tree) %.>%
print(.)
op_tree <- d %.>%
project_se(., groupby = NULL, "vmax" %:=% "max(val)")
cat(format(op_tree))
sql <- to_sql(op_tree, my_db)
cat(sql)
execute(my_db, op_tree) %.>%
print(.)
DBI::dbDisconnect(my_db)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.