title: Naming regression output in a double loop
body: <p>I have a double loop looping over power and range, both go from 1 to 5. I would like to save all regression output in the following format: f12 where power=1 and range=2, etc.  </p>
  
  <p>I would like to save regression output in a table format using Stargazer, or something similar. </p>
  
  <pre class="lang-r prettyprint-override"><code># data:
  y=rnorm(100, 0,1)
  x=sample(5, 100, replace = T)
  
  dat=data.frame(y=y, x=x)
  
  # power &amp; range:
  range &lt;- seq(1, 5, by = 1)
  power &lt;- seq(1, 5, by = 1)
  
  # loop:
  
  for (z in seq_along(power)) # power
  {
    for (j in seq_along(range)) # range
    {
        # regression    
        dat$dummy.j &lt;-  ifelse(range == j, 1 , 0 )
        f &lt;- lm(y ~ poly(x, z, raw=TRUE) + dummy.j, data=dat, na.action=na.exclude)
  
        assign(paste("f", j, sep = ""), f)
    }
  
    assign(paste("f", z, sep = ""), f)
  }
  
  library(stargazer)
  models_int &lt;- list(f11, f12, f13, f14, f21, ....)
  stargazer(models_int, type = "html", out="...")
  </code></pre>
  
  <p>I know that the second assign() is the problem, I just don't know how to solve it. </p>