View source: R/verb-group_by.R
group_by.tbl_lazy | R Documentation |
This is a method for the dplyr group_by()
generic. It is translated to
the GROUP BY
clause of the SQL query when used with
summarise()
and to the PARTITION BY
clause of
window functions when used with mutate()
.
## S3 method for class 'tbl_lazy'
group_by(.data, ..., .add = FALSE, add = deprecated(), .drop = TRUE)
.data |
A lazy data frame backed by a database query. |
... |
< |
.add |
When This argument was previously called |
add |
Deprecated. Please use |
.drop |
Not supported by this method. |
library(dplyr, warn.conflicts = FALSE)
db <- memdb_frame(g = c(1, 1, 1, 2, 2), x = c(4, 3, 6, 9, 2))
db %>%
group_by(g) %>%
summarise(n()) %>%
show_query()
db %>%
group_by(g) %>%
mutate(x2 = x / sum(x, na.rm = TRUE)) %>%
show_query()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.