I wonder if there is a simple way to produce a list of variables using a for loop, and give its value.
for(i in 1:3)
{
noquote(paste("a",i,sep=""))=i
}
In the above code, I try to create a1
, a2
, a3
, which assign to the values of 1, 2, 3. However, R gives an error message. Thanks for your help.
names
parameter and later either just use it,attach
it or convert it into an environment withlist2env
andeval
inside it. With no loops, parse or other ugly stuff. $\endgroup$list2env
is a relatively new function. And still it will produce the variables in the some environment, when the OP wants to get the variables in the top environment. So the ugliness still remains :) $\endgroup$