title: How do I not have R overwrite the other values
body: <p>Here's my function</p>
  
  <pre><code>complete &lt;- function(directory, id = 1:332) {
    files_list &lt;- list.files(directory, full.names = TRUE)
    nobs &lt;- numeric()
    for (i in id) {
      nob &lt;- sum(complete.cases(read.csv(files_list[i])))
  
    }
    nobs &lt;- c(nobs, nob)
    dat &lt;- return(data.frame(id, nobs))
  } 
  
  complete(specdata, 1)
  complete(specdata, c(2, 4, 8, 10, 12))
  </code></pre>
  
  <p>This returns</p>
  
  <pre><code>&gt; complete(specdata, 1)
    id nobs
  1  1  117
  &gt; complete(specdata, c(2, 4, 8, 10, 12))
    id nobs
  1  2   96
  2  4   96
  3  8   96
  4 10   96
  5 12   96
  </code></pre>
  
  <p>While I get the correct single values, 
  the different ids should have different ending values, 
  at the moment, all the values are overwritten by the final value.</p>
  
  <p>How do get it to not do that?</p>