Different IDEs have quirks, and so it's occasionally useful to be able to know what IDE you are using to run R.
You can test if you are running RStudio by testing for the RSTUDIO
environment variable.
is_rstudio <- function()
{
env <- Sys.getenv("RSTUDIO")
!is.null(env) && env == "1"
}
(Or, as Hadley commented, gui <- .Platform$GUI; !is.null(gui) && gui == "RStudio"
.)
You can test for Revolution R by check for a list named Revo.version
in the base environment.
is_revo_r <- function()
{
exists("Revo.version", "package:base", inherits = FALSE) && is.list(Revo.version)
}
Is there a similar check that can be done to see if you are running Architect or StatET?
The closest thing I've found is that by default Architect prepends the path to its embedded copy of Rtools to the PATH
environment variable.
strsplit(Sys.getenv("PATH"), ";")[[1]][1]
## [1] "D:\\Program Files\\Architect\\plugins\\eu.openanalytics.architect.rtools.win32.win32_0.9.3.201307232256\\rtools\\bin"
It isn't clear to me how to make a reliable cross-platform test out of this. Can you find a better test?
assertive
, which you can get vialibrary(devtools); install_bitbucket("assertive", "richierocks")
. – Technetium.Platform$GUI
– Stringed