0

[this question is edited]

I want to simplify my question - I hope that will lead to understanding enough to answer the more complex one myself.

How can I create the variables a:i in R with a for-loop?

for(i in a:i) { "create variable [i]"

}

Thank you very much for your help!

BruderK
  • 79
  • 9
  • 1
    You should include a sample of `model_daten` to make this reproducible – Patrik_P Sep 09 '17 at 08:52
  • model_daten has 1.2 milion rows and 50 columns. How should I do this? It is a dataframe. – BruderK Sep 09 '17 at 09:02
  • Read the advice [here](https://stackoverflow.com/help/mcve) or [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on creating a minimal, complete, & verifiable example for R questions. Are all 50 columns of the same type? A sample of 3-4 should suffice. Are all rows similar in nature? Take the first 20 or so. Verify that your example works with the sample, paste it here using `dput()`, & describe the desired outcome based on that sample. – Z.Lin Sep 09 '17 at 09:59

1 Answers1

-1

You can use assign

for(I in 1:6) { 
      assign(letters[I], 1)
}

Output

 list(a,b,c,d,e,f)
[[1]]
[1] 1

[[2]]
[1] 1

[[3]]
[1] 1

[[4]]
[1] 1

[[5]]
[1] 1

[[6]]
[1] 1
CPak
  • 13,260
  • 3
  • 30
  • 48
  • This has been receiving downvotes. As far as I can tell, it is relevant to OP's question, so I'll leave it up. But if OP wants to clarify, I can revise or delete my answer. To downvoters, a comment would help, but no comments work too. – CPak Sep 10 '17 at 12:30