I have some content (written in the R language) deployed to an RStudio Connect instance.
I would like to be able to do something like:
if (isTRUE(is_connect)) {
print("Running on Connect")
} else {
print("Not running on Connect")
}
That is, I'd like to have my code detect whether it is running from RStudio Connect or not, and behave differently depending on its environment.
How can I detect, using R code, whether it is running on RStudio Connect?
An alternative that I've been using is the
R_CONFIG_ACTIVE
envvar. From https://docs.rstudio.com/connect/admin/process-management/#using-the-config-package,This this, one might use
It's safe to not use
isTRUE
here, sinceSys.getenv
will always return a string of length 1; if it is unset, it returns""
(still length 1, just empty). (It's okay to useisTRUE
if you still prefer.)If you are curious what else is set within the RSC environment, see my other answer for a quick app that displays env-vars (among others).