title: read.xlsx 'Error in loadWorkbook(file): Cannot find file' R
body: <p>I am trying to read in a number of Excel files into R using <code>read.xlsx</code> using the <code>xlsx</code> package but when I do so I am getting the following error:</p>
  
  <blockquote>
    <p>Error in <code>loadWorkbook(file)</code> : Cannot find id100.xlsx</p>
  </blockquote>
  
  <p>First I list the files in the directory:</p>
  
  <pre><code>&gt; files &lt;- list.files(datDir, pattern = ".xlsx")
  </code></pre>
  
  <p>Then I use <code>read.xlsx</code> to read them all in:</p>
  
  <pre><code> for (i in seq_along(files)) {
      assign(paste("id", i, sep = "."), read.xlsx(files[i],1,as.data.frame=TRUE, 
      header=FALSE, stringsAsFactors=FALSE, na.strings=" "))
   }
  </code></pre>
  
  <p>I checked to see if the file was even in the list and it is:</p>
  
  <pre><code>&gt; files
    [1] "id100.xlsx" "id101.xlsx" etc...
  
  &gt; files[1]
    [1] "id100.xlsx"
  </code></pre>
  
  <p>I have used this code many times before today and for some reason it is just not working. I keep getting that error. Does anyone have any suggestions?</p>
  
  <p>Thanks!</p>