title: Create a matrix from a function and two numeric data frames
body: <p>I'm trying to create matrices of various distance/association functions in R.  I have a function similar to cor that gives the association between two vectors.  Now I want to take a dataframe (or matrix) of numeric vectors, something like <code>mtcars</code>, and create a matrix from the function and data frame.  I thought this is what <code>outer</code> is for but am not getting it to work.  Here's an attempt using cor and <code>mtcars</code>.</p>
  
  <pre><code>cor(mtcars$mpg, mtcars$cyl)  #a function that gives an association between two vectors                  
  outer(mtcars, mtcars, "cor") #the attempt to create a matrix of all vectors in a df
  </code></pre>
  
  <p>Yes I know that <code>cor</code> can do this directly, let's pretend it can't.  that <code>cor</code> just finds correlations between two vectors.</p>
  
  <p>So the final goal would be to get the matrix you get from <code>cor(mtcars)</code>.</p>
  
  <p>Thank you in advance.</p>