I want to cbind a column to the data frame with the column name dynamically assigned from a string
y_attribute = \"Survived\" cbind(test_data, y_attribute =
We can use tidyverse to do this
tidyverse
library(dplyr) test_data %>% mutate(!! y_attribute := NA) # col1 Survived #1 1 NA #2 2 NA #3 3 NA #4 4 NA #5 5 NA
test_data <- data.frame(col1 = 1:5)