title: Error in file(file, "rt") : cannot open the connection - cannot open file 'specdata' access denied
body: <p>I'm running rStudio v3.1.2 on Windows 7.  This laptop is a 64-bit machine.</p>
  
  <p>I'm taking the JHU R Programming course offered by Coursera and am stuck on an error I'm receiving in part 1 of the problem.  I have some error handling functions I'm keeping out of this example so I'm really just trying to show what I absolutely need to.  The only reason I include the messages is the demonstrate that all the conditions must be satisfied in order to proceed.</p>
  
  <pre><code>  pollutantmean &lt;- function(directory, pollutant, id=1:332) {
  
    setwd("C:\\Users\\WR-eSUB\\specdata")
  
    if(!isValidDirectory(directory)) {
          stop("Invalid input given.  Please specify valid directory to operate on.")
    }
    if(!isValidPollutant(pollutant)) {
          stop("Invalid input given.  Please specify valid pollutant (nitrate/sulfate).")
    }
    if(!isValidIdRange(id)) {
          stop("Invalid input given.  Please specify valid id range (1:332).")
    }
    sortedData = numeric()
    for (i in id) {
          thisFileName = paste(formatC(i, width = 3, flag = "0"), ".csv", sep="")
          thisFileRead = read.csv(directory, thisFileName)
          sortedData = c(sortedData, thisFileRead[[pollutant]])
    }
    mean(sortedData, na.rm = TRUE)
  }
  </code></pre>
  
  <p>Note that inside WR-eSUB is a folder called specdata and inside <strong>that</strong> folder there is the directory that contains the .csv files also called specdata.  I could change this but so far I've been working with it and I have not stumbled into any problems.  </p>
  
  <p>When I call <code>pollutantmean("specdata", "nitrate", 1:2)</code> I get the following error message:</p>
  
  <pre><code> Error in file(file, "rt") : cannot open the connection 
   In addition: Warning message: In file(file, "rt") : cannot open file 'specdata': Permission denied
  </code></pre>
  
  <p>Now in my numerous attempts to try and finish this part of the assignment I've been able to extract the data in other ways using things like lapply but because I kept getting stuck I threw everything out and wanted to try things this way.</p>
  
  <p>I've searched the web to try and find this solution.  Despite the fact there are several answered inquiries none of them seem to be quite as confusing as this one is.  WR-eSUB is an administrative folder but previous attempts to open files within it haven't produced this error before.</p>