title: How to use cor.test in an apply function?
body: <p>I have a really large csv file (dat2) and I'm trying to use cor.test to get a p value comparing one column (Age) to multiple other columns (every column after Age). Then I need to print the p value. I got it to work using a for loop, but it takes a really long time. I want to use an apply function because I think it will shorten the compile time? </p>
  
  <p>The ## portion is the for loop that works. </p>
  
  <pre><code>b &lt;- apply(dat2[,-1], 1(,4:ncol(dat2)), cor.test(dat2(Age), method="pearson", use="pairwise"))
  sapply(b, "[[", "p.value")
  
  ## for (i in 4:ncol(dat2)) {
  ## a &lt;- cor.test(dat2[,3], dat2[,i], method="pearson", use="pairwise")
  ## print(paste(colnames(dat2)[i], " p=value:", a$p.value))
  ## }
  </code></pre>