I have a python script that I want to run from within R using the reticulate package. I want to assign some variables in R first, and then pass them to the script. Unfortunately when I run the script, I am surprised to see that python can't recognize the variables. What am I missing here? Thanks
Python script (test.py
):
print(x)
R code:
library(reticulate)
x <- 5
source_python(test.py)
The error:
Error in py_run_file_impl(file, local, convert) :
NameError: name 'x' is not defined