I have wirked through Hadley's paper called " Programming with dplyr" but can't get the following function to work. I have simplified it to illustrate the problem but it is part of a larger function that works except for this part.
library(dplyr)
data <- tibble(a = c(1,2,3,4,5),
b = c(1,2,3,4,5))
# This is the desired outcome
data %>%
rename("b1" = b)
# This is the function
rename_var <- function(data, rename_text){
data %>%
rename(rename_text = b)
}
# call the function
rename_var(data = data, rename_text = "b1")
When I call the function then the variable is now named as rename_text and not b1.
Any assistance with this will be greatly appreciated.
Dawie