I know it is bad practice and i know it is easier with a list. But just of interest.
I have variables a1, a2, a3, ..., a"n"
Is something like this possible:
for i in (1:n)
{
a"i" <- i
}
Thanks for your reply!
I know it is bad practice and i know it is easier with a list. But just of interest.
I have variables a1, a2, a3, ..., a"n"
Is something like this possible:
for i in (1:n)
{
a"i" <- i
}
Thanks for your reply!
Yes,
assign(paste('a', i, sep=''), 'hello')
Should do the trick. And yes, it works even if the variable already exists.
get(paste('a', i, sep=''))
Gives you the value of the variable a1.