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") |