How to loop through a folder of CSV files in R
<p>I have a folder containing a bunch of CSV files that are titled "yob1980", "yob1981", "yob1982" etc.</p>

<p>I have to use a for loop to go through each file and put its contents into a data frame - the columns in the data frame should be "1980", "1981", "1982" etc</p>

<p>Here is what I have:</p>

<pre><code>file_list &lt;- list.files()

temp = list.files(pattern="*.txt")
babynames &lt;- do.call(rbind,lapply(temp,read.csv, FALSE))

names(babynames) &lt;- c("Name", "Gender", "Count")
</code></pre>

<p>I feel like I need a for loop, but I'm not sure how to loop through the files. Anyone point me in the right direction?</p>