Related: Strings as variable references in R Possibly related: Concatenate expressions to subset a dataframe
I\'ve simplified the question per the comment
If you want to use a string as a variable name, you can use assign:
var1="string_name" assign(var1, c(5,4,5,6,7)) string_name [1] 5 4 5 6 7