Skip to content

Instantly share code, notes, and snippets.

@toyeiei
Created January 31, 2019 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toyeiei/668465f3a47418715ead37ba9e730267 to your computer and use it in GitHub Desktop.
Save toyeiei/668465f3a47418715ead37ba9e730267 to your computer and use it in GitHub Desktop.
glimpse dplyr 2
# 4. create new columns
mtcars %>% mutate(hp_2 = hp * 2)
mtcars %>% mutate(log_hp = log(hp))
# 5. summarise statistics
mtcars %>%
summarise(mean_hp = mean(hp),
sd_hp = sd(hp),
n = n())
# 6. group_by() always used with summarise()
mtcars %>%
group_by(am) %>%
summarise(mean_hp = mean(hp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment