Description Usage Arguments Value Examples
This function changes the value of a data frame's column, then binds back to itself in order to fit into a pipeline. This preserves grouping, and if group
is a factor, returns group
as a factor with expanded levels.
1 |
.data |
A data frame. |
group |
Bare column name of the column needing to be changed. |
new_value |
String giving the new value for column |
append |
Logical: should new values be appended to the end of |
.id |
Optional, inheriting from |
A data frame with twice as many rows as the original.
1 2 3 4 5 6 7 8 9 10 11 12 | town_populations <- data.frame(
name = c("East Haven", "Hamden", "West Haven"),
pop = c(29015, 61476, 54972)
)
town_populations %>%
dplyr::mutate(measure = "total_pop") %>%
bind_self(group = name, new_value = "Inner Ring towns")
town_populations %>%
dplyr::group_by(name) %>%
bind_self(group = name, new_value = "Inner Ring towns") %>%
dplyr::summarise(pop = sum(pop))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.