I use both R and Python a lot, sometimes both even in the same project. Unfortunately, the IDEs for both languages are kind of lacking - there’s no good cross-language IDE for scientific workflows. If you’re caught in this situation, it can be pretty frustrating - no one enjoys using one IDE for language A, another IDE for language B, and a third for language C. Atom and its Hydrogen extension solves this issue nicely.

Although RStudio is really awesome when working with R, it is of absolutely no help when working with Python or any other language. Python IDEs are all over the place. Jupyter Notebooks are extremely clunky to work with, and you can’t use them for most types of real-world work (writing scripts, programs, etc). On the other hand, heavyweight Python editors like PyCharm don’t quite do interactive work like exploring data as well (though the latest version of PyCharm Pro has a data science extension, it’s still fairly awkward to use and feels very tacked-on).

The closest equivalent is Jupyterlab, but that’s still in the very early stages of development. Although it’s supposedly ready for use now, I’ve tested it out a bit, and there’s very heavy lag when typing, and it’s still missing key features like documentation lookup, refactoring tools, etc. when working on a Python script. The lag is the biggest issue preventing adoption for me - characters often take about a second to show up after typing, which is simply not acceptable performance for an IDE.

What I want (and probably you, if you’re reading this…) is an editor that does the following things nicely:

  • Allows working with R and Python (and ideally other languages) in a consistent manner. We don’t want first-class support for one language, with everything else a distant second.
  • Graphics and output are displayed in the IDE in a convenient location. No pop-up windows!
  • We can execute code line-by-line interactively like in RStudio.
  • There’s a nice integrated terminal, where we can work interactively in the same environment as our “line-by-line” execution above (again, just like RStudio).
  • All the usual IDE tools are available and more or less usable (autocompletion/etc.).

Anyhow, after several years of trying to make a number of different editors work (I’ve tried PyCharm, VSCode, Vim + IPython, Jupyter Notebooks, Jupyterlab, RStudio), I finally decided to give Atom another go. It works rather nicely! Take a look:

R notebook-style code execution!

Mmmmm… look at all those inline results, and the environment is even shared with the integrated terminal! (Basically all of the good bits about RStudio.)

The same, but with Python!

First time I’ve ever got this working for two languages in a real IDE (Jupyter notebooks don’t count!).


Usually, I try to test things out for a substantial amount of time before making a blog post about it. This gives me more time to test things out and make sure I don’t overlook anything really obvious. In this case I’m making an exception. I set up Atom today, and it’s such an improvement over my usual editors (Vim and Visual Studio Code) that I’m just going to go out and blog about it now… (hold my beer)

Download and setup R and Python

If you haven’t already, you’ll want to get R and Python setup and configured for use with Atom. There’s a few things to note here - we’re going to install everything through Anaconda instead of using the R/Python package managers. Why? It makes things a lot easier to setup and consistent across both languages (and faster, if you’re on Linux - no need to kiss your computer goodbye for an hour while tidyverse and friends compile).

Installing Anaconda

Though you could install the full Anaconda distribution through the installer - it’s a huge download and you’re likely to never use all of the bundled packages. Instead, we’ll download Miniconda, and install only what we need.

# GUI installers are available at https://conda.io/miniconda.html
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

You’ll want to add the Miniconda binaries to your system PATH on Linux. I recommend adding it to the end of your PATH to avoid replacing the system Python with Miniconda’s. A sample .bashrc entry might look like this:

# if miniconda was installed in your home directory,
# otherwise edit as appropriate...
export PATH=$PATH:~/miniconda3/bin

Setup Python and your Python kernel

Setting up Python packages is easy. Just conda install everything you need. This should be a familiar process to many Python users. I made a mention of a “kernel” in the header for this section, this is the Python process that will execute our code and interact with our editor.

# install some example packages:
conda install numpy pandas seaborn scikit-learn requests
# these packages are absolutely required:
conda install ipython ipykernel python-language-server

Setup R and the R kernel

We’ll install R and it’s packages through conda. This will be a bit of a weird process for most R users, usually you use an installer/package manager to install the base R language and install.packages() to install packages. We’re not going to do that here. The main reason is that you don’t need to worry about your R installation through conda. Conda ships a nice, pre-compiled R installation that is significantly faster to install and virtually guaranteed to work on your setup. It can be tough to get the R kernel working with the normal version of R, and this sidesteps that problem entirely:

# install as many r packages as possible through conda
conda install r-essentials r-igraph
# install the R language server used later on
Rscript -e 'install.packages("languageserver")'

Download and configure Atom

You can install Atom from the official website in whatever manner works for you. In this case, I’ll use the system package manager:

wget https://atom.io/download/rpm -O atom.rpm
sudo dnf -y install atom.rpm

This entire setup is based around several Atom extensions:

  • Hydrogen - a Jupyter-like extension that lets us execute code interactively. Results of code appear inline as we execute them and do not clutter up version control or modify the file in any way (just like R notebooks!). The name is actually a pun - Hydrogen is the primary component of the planet Jupiter (Jupyter is the tool that Hydrogen wraps).
  • PlatformIO IDE Terminal - an integrated terminal for Atom.
  • Hydrogen Launcher - this lets us connect Hydrogen to the PlatformIO terminal so that they can share the same interactive session.
  • Atom IDE and its Python and R extensions. These provide most IDE functions like syntax highlighting, autocompletion, etc.

Let’s install these extensions now:

# install hydrogen and terminal
apm install hydrogen hydrogen-launcher platformio-ide-terminal
# install language/IDE plugins
apm install atom-ide-ui ide-python ide-r language-r

The language-r extension appears to be fairly new, and requires a bit of patching to avoid an error message on startup (does nothing, but still…). If your curious what’s going on here, there are two duplicate snippets with the same name (which makes Atom complain), so we are renaming the duplicates.

sed -i '0,/Grep/{s/Grep/Grep 2/}' ~/.atom/packages/language-r/snippets/language-r.cson
sed -i '0,/Cummulative max/{s/Cummulative max/Cummulative max 2/}' ~/.atom/packages/language-r/snippets/language-r.cson

The sed commands will only work on Linux (it requires GNU sed), so if you are on macOS/Windows, you’ll need to find and edit the ~/.atom/packages/language-r/snippets/language-r.cson file to change the duplicate entries (Grep, and Cummulative Max) to a different name. (I actually hand-edited the files myself, just wanted to provide a command to make things easier for people following along.)

We’ll now need to install our R and Python kernels so that Hydrogen knows about them. You may need to supply the path to Minconda’s python3/Rscript binaries explicitly if you have other copies of them on your system.

python3 -m ipykernel install --user
Rscript -e 'IRkernel::installspec()'

All that’s left to do now is start up Atom and start using our extensions! Some quick tips to get you started (you can change these hotkeys in the package preferences):

Line-by-line code execution: Shift-Enter

Toggle the integrated terminal: Ctrl-` (Control + the backtick key)

Start a terminal linked to your R/Python kernel: Ctrl-Alt-Shift-J

Other Hydrogen/Terminal commands: Control-Shift-P (start typing for what you want to search for and hit Enter to execute.)

Now you can interactively code in both languages in a consistent manner. There’s also support for other languages like Kotlin, Julia, and pretty much every other language out there (any Jupyter kernel should work with Hydrogen). You can also supposedly even connect to a remote kernel, which is a really awesome feature (though I haven’t tried that out yet…). Have fun!