title: Calculate Correlation Coefficient Between 2 Variables Grouped by a 3rd Variable
body: <p>I have an excel spreadsheet with 3 columns. The first column is the id of a picture which groups the data together, and the 2nd and 3rd columns are the values I am trying to find a correlation coefficient for. </p>
  
  <p>For example: </p>
  
  <pre><code>ID  Dat1 Dat2
  130 4   4.3
  130 7.5 5
  130 6.6 6
  180 5.6 
  180 5   8.7
  180 7.1 5
  </code></pre>
  
  <p>In that example, the data is grouped by the values in the 1st column and then they have separate data in the 2nd and 3rd columns. I'm not sure whether it would be easier to find the correlation coefficients for each grouping using excel or R. </p>
  
  <p>I have tried the Data Analysis add-in in Excel but it won't work for 3 columns. </p>
  
  <p>Thanks in advance!</p>
  
  <p>The real data has hundreds of thousands of lines of data. This is just an example.</p>