title: Error in `[<-`(`*tmp*`, , subscript out of bounds subscript out of bounds
body: <p>In the following code, I am trying to create a matrix that will list off the opt.lam for each city. Upon running the loop, the first two cities always work, and then I get an error for any cities after that. </p>
  
  <p>This is the error that I get. (coefmatrix works fine, it's just the lambdamatrix that produces this error).</p>
  
  <p>Error in <code>[&lt;-</code>(<code>*tmp*</code>, , i, value = c(0.577199381062121, 0.577199381062121,  : 
    subscript out of bounds</p>
  
  <p>Here is my code: </p>
  
  <pre><code>lambdamatrix &lt;- matrix(nrow=n,ncol=2)
  rownames(lambdamatrix) &lt;- cityIDs
  colnames(lambdamatrix) &lt;- c("lambda.min","lambda.1se")
  for (i in 1:n) {
    data &lt;- subset(simdata, city==cityIDs[i])
    x &lt;- as.matrix(data.frame(data[,3:24]))
  cvfit &lt;- cv.glmnet(x, data$Y, family="poisson", offset=log(data$population))
  opt.lam &lt;- c(cvfit$lambda.min, cvfit$lambda.1se)
  fit &lt;- glmnet(x, data$Y, family= "poisson", offset=log(data$population))
  abline(plot(fit, "lambda", label= TRUE, 
              main = cityIDs[i]), v=log(opt.lam), lty=2, lwd=3, 
                                      col=c("red","dark green"))
  coefmatrix[,i] &lt;- coef(fit, s=opt.lam[1])[1:23]
  lambdamatrix[,i] &lt;- c(cvfit$lambda.min, cvfit$lambda.1se)[1:n]
  }`
  </code></pre>