I would like to produce the names of my variables automatically in R. For example in this code below, I tried to generate the variable name using paste0
and associate the names in a vector inside a for
structure.
names = c('john', 'marie', 'joe')
for(i in 1:length(names)){
paste0('summary_of_', names[i]) = 2
}
It does not work and this error was shown:
target of assignment expands to non-language object
Is it possible to create the variable names in a similar way?