Use R to look for files in all sub-directories : <p>I am on a machine running Windows 10 with RStudio (0.99.893). I am running into a problem whereby I want to include ALL filetypes (.cnv) into one dataframe. In the past all the files have been in one directory so this following has worked fine:</p>

<pre><code>setwd(directory path)
df &lt;- c()
for (x in list.files(pattern="*.cnv")) {
u&lt;-read.table(x)
      u$Filename = factor(x)
      df &lt;- rbind(df, u)
}
</code></pre>

<p>Now I am faced with a situation where there are several sub-directories with irregular names. Before I was telling R "move to this directory, look for all files with .cnv, then combine them into one dataframe". Now I need to tell R "move to this directory, look in this directory and all sub-directories for files with .cnv then combine them into a dataframe. </p>

<p>Any idea how I might accomplish within R?</p>
