run external script by system2 in R

84 views Asked by At

I have Shiny App, one of its functionalities is to run an external script in separate session. I do it with the code:

system2(command = "RScript", args = c("--vanilla",  "external_script.r"), wait = FALSE)

This works fine when the external_script.R script is in the same path as the main application. The problem comes when I want to change the path of this script. I don't know where to put the new path so I can continue using the script. I tried:

system2(command = "RScript", args = c("--vanilla",  file.path("new_path", "external_script.r")), wait = FALSE)

but it failed. Could someone help me do this correctly?

0

There are 0 answers