title: specifying a numeric list within a function
body: <p>I am writing the following function that creates a correlation matrix and finds highly correlated (>0.75) values: </p>
  
  <pre class="lang-r prettyprint-override"><code>var.cor &lt;- function(data, cols){
    cor.mat &lt;- cor(data [, cols])
    cor.mat &lt;- round(cor.mat, 2)
    high.corr &lt;- findCorrelation(cor.mat, cutoff = 0.75)
    print(cor.mat)
    print(high.corr)
  } 
  </code></pre>
  
  <p>I want to give the function a range of column numbers (i.e., <code>var.cor(data =</code>dat<code>, 10:20)</code> will run the function for columns 10:20. what is the correct way to specify <code>cols</code> in the second line of the function? when I run <code>var.cor("dat1", 10:20)</code> I get an error message: 
  <code>Error in data[, cols] : incorrect number of dimensions</code></p>