/R_Python.py Secret
Last active
December 30, 2017 18:45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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