Safely access the RStudio API

WWW: https://rstudio.github.io/rstudioapi
