I am relatively new to R and dplyr library. How can I get the function to use the name of the mutated columns as the argument pass in the function?
For example, I want "test" as the name of the mutated column but I get "y". What am I doing wrong? Thank you
library(dplyr)
d <- data.frame(alpha=1:3, beta=4:6)
d
compare_status<-function(x,y){
x %>% mutate(y=ifelse(alpha ==2,"G2","0"))
}
compare_status(d,test)
c(x=1)rather thanc("x"=1). At this point, even if the R gods saw fit to evaluate the left-hand side, they couldn't because so much code written in the past is depending on the value entered being the value shown. Too late to change.