Correlation analysis for binary variables in R
<pre><code>dat &lt;- as.data.frame(replicate(100,sample(c(0,1),100,replace=TRUE)))
</code></pre>

<p>I want to create a 100 by 100 matrix with the correlation coefficients between these binary variables as entries.</p>

<p>If the variables were continuous, then I would have used <code>cor()</code> to create the matrix. I am not sure if <code>cor()</code> with Pearson as the method is reasonable. If not, say I could find a function <code>fn()</code> to calculate the correlation between a pair of binary vectors. What is an efficient way to construct the 100 by 100 matrix?</p>