I have function in python as following :
def print_hello():
print("hello")
Rather than writing to python file and reading it from file using source_python. I would like just pass function as string and convert into R.
similar to following things
library(reticulate)
myPythonFunction <- "def print_hello():
print("hello")
"
source_from_string(myPythonFunction)
print_hello()
Does reticulate package has this function ??
There is py_run_string to execute the module and the function 'print_hello' is called from the python env by py$
library(reticulate)
myPythonFunction <- "def print_hello():
print('hello')"
py_run_string(myPythonFunction)
py$print_hello()
#hello
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With