Created
May 27, 2019 18:35
-
-
Save pbaylis/4caa0b928a5c56ce6c8f56a4e58c08d1 to your computer and use it in GitHub Desktop.
Dynamic variable names with dplyr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multipetal <- function(df, n) { | |
varname <- paste("petal", n , sep=".") | |
mutate(df, !!varname := Petal.Width * n) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: SO post