title: How to extract the p.value and estimate from cor.test()?
body: <p>I perform cor.test for a dataset in a for loop, but I don't know how to extract the information like estimate and tau from my test.</p>
  
  <p>Before performing for loop in the dataset, The cor.test() function returns as follows:</p>
  
  <p><code>cor.test(armpit$Corynebacterium.1, armpit$Staphylococcus.1, alterantive="two-sided", method="kendall", exact=FALSE, continuity=TRUE)</code></p>
  
  <p><a href="https://i.stack.imgur.com/IaGlD.png" rel="nofollow noreferrer">return result</a></p>
  
  <p>Here is my code for performing for loop. Now I want to extract estimate and tau from my test.</p>
  
  <pre><code>for (i in 1:8) {
    for (j in 1:8) {
      if (j != i)
      cor.test( as.numeric(unlist(armpit[i])),
          as.numeric(unlist(armpit[j])), alterantive="two-sided",
          method="kendall", exact=FALSE, continuity=TRUE)
     }
  }
  </code></pre>
  
  <p>I have check the similar question from </p>
  
  <p><a href="https://stackoverflow.com/questions/28577135/how-to-extract-the-p-value-and-estimate-from-cor-test-in-a-data-frame">similar question</a></p>
  
  <p>Then I change my code as:</p>
  
  <pre><code>estimates = numeric(50)
  pvalues = numeric(50)
  for (i in 1:8) {
    for (j in 1:8) {
      if (j != i)
      cor.test( as.numeric(unlist(armpit[i])),
          as.numeric(unlist(armpit[j])), alterantive="two-sided",
           method="kendall", exact=FALSE, continuity=TRUE)
      estimates[i] = cor.test$estimate
      pvalues[i]= cor.test$p-value
     }
     }
  </code></pre>
  
  <p>But it returns:</p>
  
  <p><code>Error in cor.test$estimate : object of type 'closure' is not subsettable</code></p>
  
  <p>Could anyone offer me some help about how to extract estimate and tau value from cor.test() function in a for loop? Thanks in advance.</p>