I'm using source_python()
function to run a Python Script via user interface of R Shiny. Code is running properly and I'm successful in it. But I want to run a function named function2()
which is in Task3.py
. Can I do this? If yes then how can I do this? I just want to execute function2()
. I don't want function1()
and function3()
to run. I'm doing this by using following lines and syntax which I found by Googling. I'm unsuccessful in running just function2()
by following below link. The link that I followed is:
https://rstudio.github.io/reticulate/articles/calling_python.html
server.R:
library(reticulate)
observeEvent(input$action,{
py_run_file("applications/Task3.py")
function2()
})
Task3.py:
def main(argv):
function1()
....
function2()
....
function3()
....
if __name__ == "__main__":
try:
k=sys.exit(main(sys.argv))
except (ValueError, IOError) as e:
sys.exit(e)