title: Applying CCF to all files in a folder & creating new table with results
body: <p>I'm quite new with R and am attempting to run a cross-correlational analysis on two columns in a file. I have multiple such files (each corresponding to a pair of values that need to be compared). I would like to store the results of each ccf in a new table. This is what I have written so far:</p>
  <pre><code>RSA_sync &lt;- list.files(path=&quot;C:/Users/plore/OneDrive/Documents/Active Self iBreath project/Data Analysis/dyadRsaData&quot;,
      pattern = &quot;_detrended.csv&quot;, full.names = TRUE)
      
      
  #Creating function to apply to all files in directory
      
  dfList &lt;- lapply(RSA_sync, function(i) {
      df &lt;- read.csv(i, sep = &quot;;&quot;)
      cc &lt;- ccf(df$motherRsa, df$infantRsa, lag = 0, plot = FALSE) #Only interested in lag0 value
      #insert ccf and save in dew df
      write.csv (cc, &quot;ccf.csv&quot;, quote = F, row.names = F)
      })
  </code></pre>
  <p>However, I am getting the following error:</p>
  <pre><code>Error in as.data.frame.default(x[[i]], optional = TRUE, stringsAsFactors = stringsAsFactors) :
  cannot coerce class ‘&quot;acf&quot;’ to a data.frame
  </code></pre>
  <p>Does anyone know how to solve the issue? Many thanks in advance.</p>