title: R - Getting warnings: "only the first element is used as variable name"
body: <p>I'm trying to use "assign" function, inside a for loop, to assign the value of a file to one variable.</p>
  
  <p>When I call the function, it brings the correct answer but in the end it gives me the following warning messages:</p>
  
  <pre><code> In assign(fileList, read.csv(fileList[i])) :
   only the first element is used as variable name
  </code></pre>
  
  <p>If I run > corr("specdata", 129) I can see the correct answer, it can print all the right values, but If I assign the values to any variable for example, it says that this variable is "NULL". An example:</p>
  
  <pre><code>cr &lt;- corr("specdata", 150) 
  head(cr)
  NULL
  </code></pre>
  
  <p>It will give me all the values that fit in this criteria but it seems that it can't pass the values to "cr". Other examples:</p>
  
  <pre><code>&gt; class(cr)
  [1] "NULL"
  &gt; cr
  NULL
  </code></pre>
  
  <p>The code that I'm currently using, if is helpful:</p>
  
  <pre><code>corr &lt;- function(directory, threshold){
      if (directory == "specdata"){ 
          setwd("C:/Users/User/Downloads/specdata")
  
          fileList &lt;- list.files(pattern="*.csv")
          for (i in 1:length(fileList)){
              fileValues &lt;- assign(fileList, read.csv(fileList[i]))
              okValues &lt;- na.omit(fileValues)
              completeCases &lt;- sum(complete.cases(okValues))
              if (completeCases &gt; threshold) {
                  sulfate &lt;- okValues["sulfate"]
                  nitrate &lt;- okValues["nitrate"]
                  correlation &lt;- cor(sulfate, nitrate,  use="complete.obs", method=c("pearson", "kendall", "spearman")) 
                  #print(correlation)
  
              }
  
              else if (completeCases &lt;= threshold){
                  #print("0")
              }
  
              i = i+1
          }
      }
  
      else {
          print("There's no such directory")
      }
  
  }
  </code></pre>
  
  <p>I'm a begginer on R language, so, if there's any way to fix this issue or to read every single file from a folder and manipulate separately, I'd be glad.</p>