0

I'm running a very long for loop with many variables and functions, and need to save the results in lists. Therefore, I want to prepare empty lists before hand. I can do it like this, but it's ugly and makes me uncomfortable:

df = list()
EV = list()
var = list()
design = list()
contrast = list()
d = list()

Is there a better way? thanks.

Programming Noob
  • 1,232
  • 3
  • 14
  • Can you change your for loops with lapply? Then you would create them automatically? – zx8754 Oct 09 '22 at 20:21
  • 2
    What part is uncomfortable? Maybe try `x <- y <- z <- list()` https://stackoverflow.com/a/13385041/680068 – zx8754 Oct 09 '22 at 20:24
  • 2
    @zx8754 I don't think I can, the for loop is far too long and has many variables and functions. It is applied to run over an analysis applied on several datasets. The solution you provided is just what I need, thank you! – Programming Noob Oct 09 '22 at 20:33

0 Answers0