Last active
May 3, 2016 08:08
-
-
Save Nicktz/2363d21d253663f61083f2185b0ada7c to your computer and use it in GitHub Desktop.
This file contains 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
SetNames allows a mutate function to design a formula and rename the new mutated column accordingly. It works perfectly well across vectors as well. | |
Another benefit is that setNames can then also be run to check the formula: | |
E.g. to create a % column for Variable: | |
Variable <- "FactorX" | |
DF %>% | |
mutate_(.dots = | |
setNames( paste0(Variable,"/sum(",Variable,", na.rm = TRUE))"), paste0(Variable, "Pct")) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment