title: converting list to data frame with specific column names in R
body: <p>I've reviewed the other similar threads on here but haven't found the answer to my question yet. I'm building a list in a for loop that I want to convert to a data frame. The final list looks like this:</p>
  
  <pre><code>[[1]]
  [1] 117
  
  [[2]]
  [1] 1041
  
  [[3]]
  [1] 243
  
  [[4]]
  [1] 474
  
  [[5]]
  [1] 402
  </code></pre>
  
  <p>I want to convert this to a data frame, with specific column names: ID and nobs. So for example for 5th row in the data frame, the row value for ID would be 5 and the value for bobs would be 402. Running this code:</p>
  
  <pre><code>d &lt;- data.frame(cbind(l))
  </code></pre>
  
  <p>gives me the columns but without the names. How and where can I specify the column names? I am just learning R. Thanks for any help.</p>
  
  <p>this is the full code for my function:</p>
  
  <pre><code>complete &lt;- function(directory, id) {
          files_full &lt;- list.files(directory, full.names = TRUE)
          l &lt;- list()
          for (i in id){
                  nobs &lt;- sum(complete.cases(read.csv(files_full[i])))
                  l[i] &lt;- nobs
          }
          d &lt;- data.frame(cbind(l))
          d
  }
  </code></pre>