Skip to content

Instantly share code, notes, and snippets.

@pbaylis
Created May 27, 2019 18:35
Show Gist options
  • Save pbaylis/4caa0b928a5c56ce6c8f56a4e58c08d1 to your computer and use it in GitHub Desktop.
Save pbaylis/4caa0b928a5c56ce6c8f56a4e58c08d1 to your computer and use it in GitHub Desktop.
Dynamic variable names with dplyr
multipetal <- function(df, n) {
varname <- paste("petal", n , sep=".")
mutate(df, !!varname := Petal.Width * n)
}
@pbaylis
Copy link
Author

pbaylis commented May 27, 2019

Source: SO post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment