Skip to content

Instantly share code, notes, and snippets.

@briandk
Last active August 29, 2015 14:12
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 briandk/7c11e9aca5a0adc998cc to your computer and use it in GitHub Desktop.
Save briandk/7c11e9aca5a0adc998cc to your computer and use it in GitHub Desktop.
Formatting conventions for piping with magrittr in R
df <-
  df %>%
  select(col1 = str_split(oldcol2, ','),
         col2,
         col3 = paste0(oldcol1, 'amber')) %>%
  filter(col1 == "America" | col2 >= 55) %>%
  group_by(col1, col2) %>%
  summerize(count = n())
df <-
  df %>%
  select(col1, col2, col3 = paste0(oldcol1, 'amber')) %>%
  filter(col1 == "America" | col2 >= 55) %>%
  group_by(col1, col2) %>%
  summerize(count = n())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment