As a trainer of R I often work with beginners, eager to learn but somewhat overwhelmed by the sheer volume of information. This applies equally to data science concepts in general, R as a language and RStudio as an integrated development environment.

Data science (which is in my opinion less of a “science” and more like Data Housekeeping, but I digress…) is hard to reduce to a few unmutable truths. R is a powerful, and thus complex, ecosystem of Open Source packages, vibrant but unlikely to ever be easy to navigate for novice users.

On the other hand there are a few unmutable truths that can be applied to RStudio IDE that are not a part of the standard defaults. These include, but are not limited to, never saving nor restoring environment in .RData file, and strictly applying UTF-8 formatting (especially for users from non-ASCII language background).

The recent 1.3 release of RStudio has introduced a powerful new feature: the settings are now stored as a plain text file (rstudio-prefs.json) that can be manipulated programatically – e.g. by a R script.

This allows me to fulfill a long time desire; an init script for new users overriding the default settings by Jindra’s best practices.

In my trainings I can ask my students to run this script now, and thank me later.

This script, which I have made available as a gist on GitHub, overrides four settings that have been the biggest pain points:

  • saving workspace in .RData (never)

  • loading workspace from .RData (never)

  • saving history (never)

  • setting UTF-8 as default character encoding

Overriding these settings programatically is much easier than instructing my users to click the relevant checkboxes manually at the start of my trainings.

The technique can be also extended easily by more seasoned users to save their settings in a version control system, such as git in general or GitHub specifically.