title: Trying to run an R script in Python
body: <p>I have an R script that outputs a CSV that I would like to run in Python. </p>
  
  <p>For example, lets say the R script simply creates a dataframe and outputs a CSV file to my desktop.</p>
  
  <p><strong>sample.r</strong></p>
  
  <pre><code>x &lt;- c(1,2,4)
  y &lt;- c("A","B","C")
  z &lt;- data.frame(x,y)
  write.csv(z,"c:/users/username/dekstop/z.csv)
  </code></pre>
  
  <p>I'm wondering how I can call the R script in Python in order to create the output.</p>
  
  <p>I have tried utilizing the function below, however it did not create the CSV file.</p>
  
  <pre><code>import subprocess
  subprocess.call ("/usr/bin/Rscript --vanilla path/sample.r", shell=True)
  </code></pre>
  
  <p>Any help is appreciated.</p>