0

My colleague gave me a big R function and I have to use it in the pipeline which will be developed in python3. In theory I have two options:

  1. convert R into python
  2. directly use R function in python script (for example by importing like a module)

What do you suggest? and how can I do each of these options?

smci
  • 29,564
  • 18
  • 109
  • 144
user10657934
  • 137
  • 8
  • Does this link answer your question? https://stackoverflow.com/questions/19894365/running-r-script-from-python – Jon Jul 01 '19 at 13:19

1 Answers1

0

Using rpy2.robjects might help ('function.R' is the r code)

import rpy2.robjects as robjects
robjects.r.source("function.R")

result refers to the output of the function

print(robjects.globalenv["result"])
Devarshi Mandal
  • 603
  • 8
  • 16