title: Running R script from python
body: <p>I searched for this question and found some answers on this, but none of them seem to work. This is the script that I'm using in python to run my R script.</p>
  
  <pre><code>import subprocess
  retcode = subprocess.call("/usr/bin/Rscript --vanilla -e 'source(\"/pathto/MyrScript.r\")'", shell=True)
  </code></pre>
  
  <p>and I get this error:</p>
  
  <pre><code>Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
    no lines available in input
  Calls: source ... withVisible -&gt; eval -&gt; eval -&gt; read.csv -&gt; read.table
  Execution halted
  </code></pre>
  
  <p>and here is the content of my R script (pretty simple!)</p>
  
  <pre><code>data = read.csv('features.csv')
  data1 = read.csv("BagofWords.csv")
  merged = merge(data,data1)
  write.table(merged, "merged.csv",quote=FALSE,sep=",",row.names=FALSE)
  for (i in 1:length(merged$fileName))
  {
          fileConn&lt;-file(paste("output/",toString(merged$fileName[i]),".txt",sep=""))
          writeLines((toString(merged$BagofWord[i])),fileConn)
          close(fileConn)
  }
  </code></pre>
  
  <p>The r script is working fine, when I use <code>source('MyrScript.r')</code> in r commandline. Moreover, when I try to use the exact command which I pass to the <code>subprocess.call</code> function (i.e., <code>/usr/bin/Rscript --vanilla -e 'source("/pathto/MyrScript.r")'</code>) in my commandline it works find, I don't really get what's the problem.</p>