title: Objects not found when reading in a function via R Studio
body: <p>When I run my code via R-Studio I'm told I have an unexpected curly brace.</p>
  
  <p>I have four: two to open/close the function and two for the for loop. I'm then told many of the variables are not found: Unexpected "for", "directory" not found, "basedf" not found. It's as if nothing from my function is recognized.</p>
  
  <p>I tried cutting and pasting the function directly into the console but with similar errors.</p>
  
  <p>Is my function flawed, or is something else the issue?</p>
  
  <pre><code>pollutantmean &lt;- function(directory, pollutant, id = 1:332) {
      files &lt;- list.files(directory)
      subsetFiles &lt;- files[id]
      basedf &lt;- data.frame(Date = as.Date(character(),
              sulfate = numeric(),
              nitrate = numeric(),
              ID = numeric())
      for (i in subsetFiles) {
          filepaths &lt;- paste(directory,"/",i, sep='')
          basedf &lt;- rbind(basedf, read.csv(filepaths))
      }
      good &lt;- complete.cases(basedf)
      data2 &lt;- basedf[good,pollutant]
      mean(data2)
  }
  </code></pre>