This simple example illustrates the usage of get
and assign
commands in R.
test1 = 1:10
test2 = 10:1
for(i in 1:2)
{
tmp = get(paste0("test", i))
assign(paste0("test", i+2), tmp)
}
test3
test4
[1] 1 2 3 4 5 6 7 8 9 10
[1] 10 9 8 7 6 5 4 3 2 1