Check if R is running in RStudio

前端 未结 9 703
小鲜肉
小鲜肉 2020-12-09 01:46

I am looking for a way to test if R is being run from RStudio. For some reason I could find the answer on google yesterday but not today, but I think it had to do with testi

9条回答
  •  没有蜡笔的小新
    2020-12-09 02:28

    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.

提交回复
热议问题