title: What's wrong with my function to load multiple .csv files into single dataframe in R using rbind?
body: <p>I have written the following function to combine 300 .csv files. My directory name is "specdata". I have done the following steps for execution,</p>
  
  <pre><code>x &lt;- function(directory) {     
      dir &lt;- directory    
      data_dir &lt;- paste(getwd(),dir,sep = "/")    
      files  &lt;- list.files(data_dir,pattern = '\\.csv')    
      tables &lt;- lapply(paste(data_dir,files,sep = "/"), read.csv, header = TRUE)    
      pollutantmean &lt;- do.call(rbind , tables)         
  }
  
  # Step 2: call the function
  x("specdata")
  
  # Step 3: inspect results
  head(pollutantmean)
  
  Error in head(pollutantmean) : object 'pollutantmean' not found
  </code></pre>
  
  <p>What is my mistake? Can anyone please explain?</p>