Skip to content

Instantly share code, notes, and snippets.

@csaid csaid/diamonds.R
Created Mar 30, 2016

Embed
What would you like to do?
# R
# 1) Easily create multiple summaries of multiple column.
diamonds %>%
group_by(cut) %>%
summarize(mean_x = mean(x), var_xy = var(x * y))
# 2) Easily put multiple summaries back into the original data frame
diamonds %>%
group_by(cut) %>%
mutate(mean_x = mean(x), var_xy = var(x * y))
# 3) Easily create new columns.
diamonds %>%
mutate(xy = x + y, xz = x + z)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.