DataFrame, "data1", has column names "standard", "voffset", "temp", "loop_div". I am able to create a new column, "legend", using mutate:
data2=mutate(data1,legend = paste(standard,voffset,temp,loop_div, sep="_"))
However, I would like to create a variable to contain the column names to use in mutate, instead, because the columns to use will change depending on the dataframe I am using. I have tried using a single quoted string as follows:
legend_cols='standard,voffset,temp,loop_div' data2=mutate(data1,legend = paste(legend_cols, sep="_"))
This produces "standard,voffset,temp,loop_div" for every value in the legend column of the dataframe, data2$legend. This is because I've lost the reference to the actual columns.
How can I create column references in my legend_cols string variable, or is there a better approach to mutate with a variable set of columns?