title: Cor function returning single value instead of multiple in R language
body: <p>I am trying to apply cor function to a data set. Below is my code: </p>
  
  <pre><code>corr &lt;- function(directory, threshold = 0) {
        for (i in 1:332) {
        data = read.csv(paste(directory, '/',
            formatC(i, width = 3, flag = '0'), '.csv', sep = '')) # reading all files
        }
        cv = numeric() #initializing list
        data = na.omit(data) #omitting NAs from read file
        if (nrow(data) &gt; threshold) { 
            cv = c(cv, cor(data[,2], data[,3])) #if number of rows more than threshold, get correlation of data
        }
       cv
   }
  </code></pre>
  
  <p>In command line, I can then call:</p>
  
  <pre><code>cr &lt;- corr('specdata', 150)
  head(cr)
  </code></pre>
  
  <p>My expected output is:</p>
  
  <h1>[1] -0.01896 -0.14051 -0.04390 -0.06816 -0.12351 -0.07589</h1>
  
  <p>but the return value I get is only:</p>
  
  <h1>[1] -0.01896</h1>
  
  <p>I don't fully understand cor and why I am getting this result, please help. All my CSV files contain normal tables. Thank you!</p>