0

I want to save variables with different names. I made simplified form of my code.

a <- runif(10, 1, 10)
for (i in 1:10)
{
 b = a[i]
}

I want to save variables with names such as b_1, b_2, b_3, b_4, ... b_10.

How can I change the variable names.

I think this might be simple, but...do not know. Thank you in advance.

Jihoon
  • 23
  • 1
  • 4
  • Don't do that (really there is no reason to do that!). Put them into a `list`. – Roland Jan 05 '15 at 16:34
  • Instead of b_1 what is wrong with a[1]? @Roland For their example I don't even think a list is necessary. – Dason Jan 05 '15 at 16:34
  • @Dason Sure, but it's a simplified example. – Roland Jan 05 '15 at 16:35
  • @Roland Most likely but it might not be. Still - either using direct indexing or using a list is definitely a better approach. – Dason Jan 05 '15 at 16:36
  • Yes, sorry to make this simple example. I think this example is a little bit stupid but straightforward. Thank you for your consideration. – Jihoon Jan 05 '15 at 16:37
  • I am just curious about how to assign different names when I want to save several datasets in for loop. – Jihoon Jan 05 '15 at 16:39

0 Answers0