title: Substitute results to an error with cor.test
body: <p>I am trying to write a loop, which returns linear regression and correlation parameters. When trying to pass substitute through <code>cor.test</code> function, I encounter an unexpected error</p>
  
  <pre><code>data(iris)
  i &lt;- 1
  vars &lt;- list(par = as.name(colnames(iris)[1]), expl = as.name(colnames(iris)[2:4][i]))
  lm(substitute(par ~ expl, vars), data = iris) # works
  lm(Sepal.Length ~ Sepal.Width, data = iris) # works. Result equal to the statement above
  
  cor.test(~Sepal.Length + Sepal.Width, data = iris) # works
  cor.test(substitute(~par + expl, vars), data = iris) # does not work
  ## Error in cor.test.default(substitute(~par + expl, vars), data = iris) :  
  ## argument "y" is missing, with no default
  </code></pre>
  
  <p>To my understanding the cor.test statement should be the same than the manually inputted one. </p>
  
  <p>What is the reason for the error? How can I write a substitute statement for <code>cor.test</code> that works?</p>