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