Utilizes 'RStudio' job scheduler if correct environment is
detected, otherwise call system command via Rscript
rs_exec(
expr,
name = "Untitled",
quoted = FALSE,
rs = TRUE,
wait = FALSE,
packages = NULL,
focus_on_console = FALSE
)R expression
used by 'RStudio' as name of the job
is expr quoted
whether to use 'RStudio' by default
whether to wait for the result.
packages to load in the sub-sessions
whether to return back to console after creating
jobs; useful when users want to focus on writing code; default is false.
This feature works with 'RStudio' (>=1.4)
If wait=TRUE, returns evaluation results of expr,
otherwise a function that can track the state of job.
'RStudio' provides interfaces jobRunScript to
schedule background jobs. However, this
functionality only applies using 'RStudio' IDE. When launching R from
other places such as terminals, the job scheduler usually result in
errors. In this case, the alternative is to call system command via
Rscript
The expression expr will run a clean environment. Therefore R objects
created outside of the context will be inaccessible from within the child
environment, and packages except for base packages will not be loaded.
There is a small difference when running within and without 'RStudio'.
When running via Rscript, the environment will run under
vanilla argument, which means no load, no start-up code. If you
have start-up code stored at ~/.Rprofile, the start-up code will be
ignored. When running within 'RStudio', the start-up code will be executed.
As of rstudioapi version 0.11, there is no 'vanilla' option. This
feature is subject to change in the future.