Although I agree with joran in this case, sometimes it can be useful to use the assign()
function, for instance as follows:
for (i in 1:3) {
assign(paste0("data.", i), i)
}
This results in the following:
> ls()
[1] "data.1" "data.2" "data.3" "i"
> data.1
[1] 1
> data.2
[1] 2
> data.3
[1] 3
2
solved Including different numbers in the names of dataframes