Skip to content

Instantly share code, notes, and snippets.

@nilforooshan
Last active October 24, 2024 11:14
Show Gist options
  • Save nilforooshan/ba24f71edd472fb04e7dccc57f2fda35 to your computer and use it in GitHub Desktop.
Save nilforooshan/ba24f71edd472fb04e7dccc57f2fda35 to your computer and use it in GitHub Desktop.
R: get & assign

get & assign

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment