You don’t need Rstudio to write R code and perhaps you shouldn’t use it

R
Opinion
Author

Gninahophin Jean-Pierre Axel

If you’re using R, chances are the first time you used it, it was inside Rstudio in a statistics class.

If you’re lucky , your professor even told you that Rstudio and R were different and don’t “belong” to the same organizations.

The Lie you believed for far too long

I can’t speak for everyone, but I assumed for a long time that using R outside of RStudio would be impossible, or at least impractical. In fact, this was the advice given by most of my professors, which I never thought to challenge.

If it’s not clear yet, this is a long-standing myth. R is well designed and you can totally use it outside of RStudio. In fact, R was meant to be used directly in the terminal, and this is exactly what I would recommend you do as much as possible.

Things you might think you need Rstudio for but you don’t

Viewing graphics

R comes battery included. So you don’t need any special software to view the charts you will generate. The only thing you might need actually to view sophisticated graphics is a web browser. If you’re reading this, you’re probably fine.

Why do you need a web browser ?

Because most interactive graphics you generate using libraries like plotly use JavaScript behind the scenes, RStudio provides you with an internal browser allowing you to view those graphics directly inside of RStudio but Firefox (or whatever browser you use) works great too. Here’s how you can define your preferred browser:

options(browser="firefox")

Auto-completion

Most IDE’s provide auto-completion nowadays. VS Code is a solid option. In fact even Vim/Neovim (my suggestion) offer R autocompletion now and it’s actually better than what you get in Rstudio if you do have the time to set it up correctly.

Editing Rmarkdown(rmd) /quarto markdown(qmd)/ shiny web apps … and rendering them

Rstudio provides a very convenient button you can just press to render your file but behind the scene it’s actually using some functions/programs you can call yourself. If you’re using quarto in a shell, you can use quarto render, and quarto preview do to exactly what you expect them to do. # But why would you use something else when Rstudio just works ?

I don’t think everyone should change but I think knowing you have options is really valuable.

In my case, I quit using RStudio because I became interested in Vim/Emacs. Vim is a lightweight text editor that you can find on most Linux machines. This is extremely convenient because you can literally use it anywhere.

It’s also highly customizable and comes with some great features that allow me to edit R code or text in general way faster than I could ever do using any other editor.

Oh…and one really cool thing: I can run R and Vim on my Android phone using Termux (Linux is lightweight!). So all I need is a Bluetooth keyboard to write code everywhere I go. And of course, using a tablet gives me an even bigger screen. You should try doing the same with Rstudio.

:)