Check if R is running in RStudio
This is from ?rstudio
:
# Test whether running under RStudio
isRStudio <- Sys.getenv("RSTUDIO") == "1"
There is also rstudioapi::isAvailable()
, but checking this is not as reliable because RStudio doesn't seem to really need the rstudioapi
package to work correctly.
Check the .Platform$GUI
option for "RStudio"
is.rstudio = function(){
.Platform$GUI == "RStudio"
}
See:
http://thecoatlessprofessor.com/programming/detecting-if-r-is-in-rstudio-and-changing-rstudios-default-graphing-device/