title: Apply confusionMatrix R function across multiple pairs of columns, saving output in lists or tidy df
body: <p>I would like to apply caret's confusionMatrix function across multiple columns, saving the results in a data-frame.</p>
  
  <p>I have two data frames of the same format - "actuals" and "predictions". They look like this:</p>
  
  <pre><code>x1   x2   x3   x4
   N    N    S    E
   E    W    E    E
   N    W    E    E
  </code></pre>
  
  <p>etc... for many rows, with 4 levels in each column, and quite a few columns</p>
  
  <p>I would like to compare the corresponding columns of the two data frames using confusionMatrix. I can do this column by column, for example starting with column 1:</p>
  
  <pre><code>confusionMatrix(predictions[,1], actuals[,1])
  </code></pre>
  
  <p>but rather than go through each column one-by-one, I would like to apply the confusionMatrix to all corresponding columns in the two data frames.</p>
  
  <p>Ideally I would like the output saved in some kind of list or data frame, so that I can easily pull out particular outputs from confusionMatrix (e.g. kappa or sensitivity) for all the comparisons. I've used purrr and broom to do something similar with the outputs from linear models, but the inputs here are quite different and I haven't been able to find a way to get this to work.</p>
  
  <p>Many thanks</p>