title: Import a number of csv files and replace NA by Zeros
body: <p>I know how to do this individually. However, I have more than 1000 files. I decided to use a for loop. However, it seems like I did not find the correct way to evaluate my variables.</p>
  
  <p>Here is my code</p>
  
  <pre><code>setwd('C:/data')
  filenames=dir() #find file names
  
  for (i in filenames){
    adt = substr(x = i, start = 1, stop = nchar(i)-4)
    name=paste("data_", adt, sep="")
    assign(name, read.csv(i,header=T,sep=",")) #read each file and assign a variable name starting with data_ to it
    func=paste('name[is.na(name)] &lt;- 0',sep="") # here is the place I have problem. R will not consider name is a parameter whose values change in each iteration
    eval((text=func))
  
    }
  </code></pre>