"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

December 31, 2017

Day #94 - Integrate R and Python

#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")
view raw R_Python.py hosted with ❤ by GitHub
Happy Learning!!!

No comments: