title: Selecting specific elements in R for cor()
body: <p>I'm in a situation where I need to find the correlation between two variables <code>cor(dataframe$x,dataframe$y)</code>, where <code>x, y</code> are column names and <code>dataframe</code> is a dataframe. One of the columns in my dataframe is an indicator function (0's and 1's).</p>
  
  <p>I'm wondering how I can compare values of x and their corresponding values of y for two separate groups (0's and 1's). I'm new to R, so I guess I'm wondering if there's built in functionality into the <code>cor()</code> function, or if I have to reconstruct a dataframe/array with <code>x's</code> and <code>y's</code> to find the correlations for separate groups. </p>
  
  <p>Guess that also leads to another question (which I've googled, it's not very clear cut to me yet): what's the difference between using a vector, array and dataframe in R under these functions (i.e. <code>cor()</code>, <code>t.test()</code>, etc.)?</p>