New way to run RStudio in OpenSAFELY
06 February 2025
We have added a new way of working with R code in OpenSAFELY, with the addition of
the opensafely launch rstudio
command.
This will start up an instance of RStudio using our official OpenSAFELY R image, and automatically open a web browser window on your computer pointing at the RStudio interface. You can edit, save, commit, and run your OpenSAFELY R code using a familiar environment, and be sure that you are using the same version of R, and all the libraries, that you will get when you run your code on our secure OpenSAFELY backends.
Previously, the only way to do this had been to use the RStudio provided with our Github Codespaces support, which is our recommended way to work with OpenSAFELY. However, this work extracts that experience, and builds on it, allowing it to be used both inside and outside of Codespaces. It will also enable us to support newer versions of R in the future, with updated libraries - watch this space!
In the process, we have improved the opensafely jupyter
command, which,
ran a JupyterLab instance in a similar fashion. This is now opensafely launch jupyter
and has seen other improvements. We hope to add other interactive
tools to opensafely launch
in the future.
We have new documentation for using opensafely launch
,
and as always, you can inspect the help options for the command with:
opensafely launch --help
If you are an OpenSAFELY R user, we encourage you to try out the bundled RStudio support, and let us know if it works well for you or not. We are always keen to get feedback on the changes we make to the system.
And finally, we want to say a big thank you to Tom Palmer for leading a lot of this work, and to the University of Bristol for seconding him to work with the Bennett Institute. Tom’s extensive knowledge of R and its ecosystem has proven immensely valuable.