title: Error in Data Frame: arguments imply differing number of rows
body: <p>Despite reading the existing answers about this Error, I still don't know how to fix this problem in my particular case.</p>
  
  <p>I have to get the sum of complete cases in a list of files. Each file (e.g. file1 corresponds to an id (e.g id1 for file1). My goal is to get a data frame with the number of complete cases for each id (therefore for each file, as file1 contains the pollutants of id1, and file2 contains the pollutants of id2 and so on)</p>
  
  <p>When I run the function: <code>complete("pollu", 1:10)</code> --> everything works perfectly</p>
  
  <h2>But when I run the functions:</h2>
  
  <pre><code> complete("pollu", 34)
  </code></pre>
  
  <p>I get ID 34 times, with 33 times returning NA and finally returning the number of complete cases.</p>
  
  <pre><code> complete(".", c(2, 4, 8, 10, 12)) 
  </code></pre>
  
  <p>I get the error: </p>
  
  <blockquote>
    <p>Error in data.frame(id, nobs) : arguments imply differing number of
    rows: 5, 12</p>
  </blockquote>
  
  <p>Any help on understanding the error and fixing it would be appreciated.</p>
  
  <pre><code>complete &lt;- function(directory,id=1:332) {
    nobs &lt;- vector()
    files &lt;- list.files(directory)
  
    for (i in id) {
      ID &lt;- id
      file &lt;- read.csv(files[i])
      nobs[i] &lt;- sum(complete.cases(file),na.rm = TRUE)
  
  }
  
  df &lt;- data.frame(ID,nobs)
  colnames(df) &lt;- c("ID", "nobs")
  return (df)
  </code></pre>
  
  <p>}</p>