title: Using load() multiple times in R script
body: <p>I'm running this R script in batch mode. The 4 file paths are passed in as named strings (inPath1...inPath3, outPath) by a shell script. Here is the shell script:</p>
  
  <pre><code>#!/bin/bash
  
  R CMD BATCH --no-save --no-restore '--args inPath1="~/backtest/results/aapl-RESULTS.RData" 
                  inPath2="~/backtest/results/adbe-RESULTS.RData" 
                  inPath3="~/backtest/results/adi-RESULTS.RData" 
                  outPath="~/backtest/profitBreakdown.csv' ~/Desktop/derp.R ~/Desktop/script.out
  </code></pre>
  
  <p>Here is the R script:</p>
  
  <pre><code>library(xts)
  
  args &lt;- commandArgs(trailingOnly=TRUE)
  
  for(i in 1:3){
    eval(parse(text=args[i]))
    pathName &lt;- paste("inPath", i, sep = "")
    load(pathName)  
  }
  </code></pre>
  
  <p>I get the following error message in the output:</p>
  
  <pre><code>Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
  Calls: load -&gt; readChar
  In addition: Warning message:
  In readChar(con, 5L, useBytes = TRUE) : cannot open compressed file 'inPath1', probable reason 'No such file or directory'
  </code></pre>
  
  <p>Why is this happening? The files and directories exist. I can double click on them and load them in with the mouse. Do I have to close the connection after using load() each time?</p>