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 =
You don't actually need cbind
to add a new column. Any of these will work:
test_data[, y_attribute] = NA # data frame row,column syntax
test_data[y_attribute] = NA # list syntax (would work for multiple columns at once)
test_data[[y_attribute]] = NA # list single item syntax (single column only)
New columns are added after the existing columns, just like cbind
.