Skip to content

Instantly share code, notes, and snippets.

@siva2k16
Last active December 30, 2017 18:45
#To invoke R Code from python there are a two options used
#Option #1 - Invoke as external R file using subprocess command
#myscript.R:
#x <- 4
#print(x)
import subprocess
subprocess.check_call(['Rscript', 'E:\\RNotes\\PetProject\\RModel\\Script.R'], shell=False)
#Option #2 - Using rpy2 package
import rpy2.robjects as robjects
r_source = robjects.r['source']
r_source("E:\\RNotes\\PetProject\\RModel\\Script.R")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment