title: Why is the following function returning NULL given non-null inputs and when it should return a vector of processed inputs?
body: <p>I have a function that is passed a list of formulas and a list of data sets. I want to take every data set and build a model using the associated formula (the inputs are in the same order and the same length so they line up). I will then return a list of the models for each formula-data pair. For some reason my function is returning <code>NULL</code> and I can't figure out why. I suspect that scoping does not work the way I think it does. The code is rather short so here it is:</p>
  
  <pre><code>models_from_formula &lt;- function(formulas, subsets) {
    out &lt;- c()
    mapply(function(f, s) {
      out &lt;- c(out, glance(lm(f, data = s)))
    }, formulas, subsets)
  
    out
  }
  </code></pre>
  
  <p>It should call my function with every pair of formula and data-set. I then create a model, use <code>broom::glance()</code> to get the information I care about, and then add it to the vector that holds my output. Somehow <code>out</code> becomes <code>NULL</code> and never changes... any ideas?</p>