title: How to iterate a function through a list of matrices
body: <p>I have a folder full of csv files that I have read and turned into matrices.</p>
  <pre><code>setwd(&quot;~/Desktop/EMD Test&quot;)
  FilesToProcess &lt;- list.files(pattern = &quot;csv&quot;)     
  listOfFiles &lt;- lapply(FilesToProcess, function(x){ out = read.csv(x, header=FALSE, stringsAsFactors = FALSE) as.matrix(out) })
  </code></pre>
  <p>Now I need to do an EMD calculation comparing all the files to the first one. Manually it looks like this:</p>
  <pre><code>emd(listOfFles[[1]],listOfFiles[[2]])
  </code></pre>
  <p>What I would like to do is run this command with all the files in ListOfFIles like</p>
  <pre><code>emd(listOfFles[[1]],listOfFiles[[x]])
  </code></pre>
  <p>I have tried several things with lapply and for loops but nothing has worked.</p>