Skip to content

Instantly share code, notes, and snippets.

@seasmith
Last active September 23, 2020 15:00
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 seasmith/f14c3d6b7d81dca69a4e6b8745763807 to your computer and use it in GitHub Desktop.
Save seasmith/f14c3d6b7d81dca69a4e6b8745763807 to your computer and use it in GitHub Desktop.
RStudio snippets
snippet .group_sum
group_by(${1:vars}) %>%
summarize(${2:value} = ${3:expression}) %>%
ungroup()
snippet .group_mut
group_by(${1:vars}) %>%
mutate(${2:value} = ${3:expression}) %>%
ungroup()
snippet .group_arr_mut
group_by(${1:vars}) %>%
arrange(${2:vars}) %>%
mutate(${3:col} = ${4:expression}) %>%
ungroup()
snippet .group_fil_mut
group_by(${1:vars}) %>%
filter(${2:cond}) %>%
mutate(${3:col} = ${4:expression}) %>%
ungroup()
snippet .group_fil_arr_mut
group_by(${1:vars}) %>%
filter(${2:cond}) %>%
arrange(${3:vars}) %>%
mutate(${4:col} = ${5:expression}) %>%
ungroup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment