title: lapply r to one column of a csv file
body: <p>I have a folder with several hundred <code>csv</code> files.  I want to use <code>lappply</code> to calculate the mean of one column within each csv file and save that value into a new csv file that would have two columns:  Column 1 would be the name of the original file.  Column 2 would be the mean value for the chosen field from the original file.  Here's what I have so far:  </p>
  
  <pre><code>setwd("C:/~~~~")
  list.files()
  filenames &lt;- list.files()
  read_csv &lt;- lapply(filenames, read.csv, header = TRUE)
  dataset &lt;- lapply(filenames[1], mean)
  write.csv(dataset, file = "Expected_Value.csv")
  </code></pre>
  
  <p>Which gives the error message:  </p>
  
  <blockquote>
    <p>Warning message: In mean.default("2pt.csv"[[1L]], ...) : argument is not numeric or logical: returning NA</p>
  </blockquote>
  
  <p>So I think I have 2(at least) problems that I cannot figure out.  </p>
  
  <p>First, why doesn't r recognize that column 1 is numeric? I double, triple checked the csv files and I'm sure this column is numeric.  </p>
  
  <p>Second, how do I get the output file to return two columns the way I described above?  I haven't gotten far with the second part yet.  </p>
  
  <p>I wanted to get the first part to work first. Any help is appreciated.</p>