title: R predict glm fit on each column in data frame using column index number
body: <p>Trying to fit BLR model to each column in data frame, and then predict on new data pts. Have a lot of columns, so cannot identify the columns by name, only column number. Having reviewed the several examples of similar nature on this site, cannot figure out why this does not work. </p>
  
  <pre><code>df &lt;- data.frame(x1 = runif(1000, -10, 10),
                   x2 = runif(1000, -2, 2),
                   x3 = runif(1000, -5, 5),
                   y = rbinom(1000, size = 1, prob = 0.40))
  
  for (i in 1:length(df)-1)
  {
          fit &lt;- glm (y ~ df[,i], data = df, family = binomial, na.action = na.exclude)
  
          new_pts &lt;- data.frame(seq(min(df[,i], na.rm = TRUE), max(df[,i], na.rm = TRUE), len = 200))
          names(new_pts) &lt;- names(df[, i])
  
          new_pred &lt;- predict(fit, newdata = new_pts, type = "response")
  
  }
  </code></pre>
  
  <p>The <code>predict()</code> function raises warning message and returns array 1000 elements long, whereas the test data has only 200 elements.</p>
  
  <p>Warning message : Warning message:
  'newdata' has 200 lines bu the variables found have 1000 lines</p>