title: pairwise combinations of coefficient and correlation p.value?
body: <p>I want to compute the pairwise combinations of coefficient and correlation pvalue for a matrix by columns.</p>
  
  <p>Here I use two functions:</p>
  
  <pre><code>allCoef&lt;- function(Y,X) {  lm(Y~X+0)$coef }
  allCorr.p&lt;- function(Y,X) {  cor.test(Y,X)$p.value }
  </code></pre>
  
  <p>For example I have a matrix of A:</p>
  
  <pre><code>A= matrix(sample(1:100,16),4,4)
  apply(Y=A,2,allCoef,X=A)
  </code></pre>
  
  <p>works fine. </p>
  
  <pre><code>apply(Y=A,2,allCorr.p,X=A)
  </code></pre>
  
  <p>However, shows Error in <code>cor.test.default(Y, X) : 'x' and 'y' must have the same length</code>. Can somebody please advise what have I done wrong here? I am using the same matrix so the length of columns should be identical.</p>