title: R find correlations between dataframes of different sizes
body: <p>I have two data frames with the same number of columns but different numbers of rows. I am trying to run correlation tests for all of the rows. I am able to do this with a for loop but because of the size of the dataset it is not a feasible option. I have found solutions for finding correlations of equal size data frames but I am not sure how to adapt these solutions.</p>
  <p>Here is my for loop solution that works for smaller datasets.</p>
  <pre><code>c.mg.spearmanB = data.frame()
  for (i in 1:nrow(brainMicroRNAs)) {
    for (j in 1:nrow(brainGenes)) {
      miRNA = brainMicroRNAs[i,]
      gene = brainGenes[j,]
      #calculate correlations and add to dataframe
      c.mg.spearmanB[i,j] = cor.test(miRNA, gene, method=&quot;spearman&quot;, exact=F)$p.value
    }
  }
  
  </code></pre>