title: Rscript: There is no package called ...?
body: <p>I want to run R files in batch mode using Rscript, however it does not seem to be loading the libraries that I need. The specific error I am getting is:</p>
  <pre><code>Error in library(timeSeries) : there is no package called 'timeSeries'
  Execution halted
  </code></pre>
  <p>However I do have the package <code>timeSeries</code> and can load it from Rstudio, RGui, and R from the command line no problem. The issue seems to only be when running a script using Rscript.</p>
  <p>My system/environment variables are configured as:</p>
  <pre><code>C:\Program Files\R\R-3.1.0\bin\x64 (Appended to PATH)
  R_HOME = C:\Program Files\R\R-3.1.0
  R_User = Patrick
  </code></pre>
  <p>I am running the same version of R in RStudio, RGui, and R from command line. I've also checked <code>.Library</code> from these three sources and got the same output as well.</p>
  <p>How can I run Rscript from command line with the packages that I am using (and have installed) in R?</p>
  <h1>EDIT:</h1>
  <p>I am using Rscript via <code>Rscript script.r</code> at the windows command line in the directory where <code>script.r</code> is located.</p>
  <p>The output of <code>Rscript -e print(.Library)</code> is <code>[1] &quot;C:/PROGRA~1/R/R-31~1.0/library&quot;</code></p>
  <p>which is consistent with the other three options that I mentioned: <code>[1] &quot;C:/PROGRA~1/R/R-31~1.0/library&quot;</code></p>
  <p>However, if I put this in my script:</p>
  <pre><code>print(.libPaths()) 
  library(timeSeries) #This is the package that failed to load
  </code></pre>
  <p>I get an output of:</p>
  <pre><code>[1] &quot;C:/Program Files/R/R-3.1.0/library&quot;
  Error in library(timeSeries) : there is no package called 'timeSeries'
  Execution halted
  </code></pre>
  <p>The corresponding call in RStudio gives an additional path to where the package is actually installed:</p>
  <pre><code>&gt; print(.libPaths())
  [1] &quot;C:/Users/Patrick/Documents/R/win-library/3.1&quot; &quot;C:/Program Files/R/R-3.1.0/library&quot;    
  
    
  </code></pre>