charliejhadley / rstudioprefswitcher

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rstudioprefswitcher

The goal of rstudioprefswitcher is to provide a programmatic tool for switching RStudio preferences. It’s designed mostly for instructors who want to switch between personal preferences and default RStudio preferences.

This package is a work in progress but is not intended for release to CRAN.

Installation

This package is not intended for CRAN, please install with remotes

remotes::install_github("charliejhadley/rstudioprefswitcher")

How to use

Let’s assume your custom settings are currently set, but to make sure there’s a drammatic change let’s programmatically change the theme to something that looks like the Matrix as follows:

rstudioapi::writeRStudioPreference("editor_theme", "Gob")

Now let’s save this combination of settings as “matrix_theme”

library("rstudioprefswitcher")
prefs_save(preferences_name = "matrix_theme")

So we can then reapply these settings, let’s change to a “light” theme.

rstudioapi::writeRStudioPreference("editor_theme", "Tomorrow")

Now let’s set our preferences back to “matrix_theme”, note that prefs_set() will reload RStudio to ensure all settings are applied.

prefs_set(preferences_name = "matrix_theme")

Resetting defaults

At present it appears the only way to reset your preferences programmatically is to delete the preference file. This can be achieved with prefs_reset_to_defaults()

prefs_reset_to_defaults()

However. RStudio maintains several default preferences from the R Console (R GUI) that contribute to poor code reproducibility, specifically:

  • Asking to save .RData on exit
  • Restoring .RData at startup
  • Always save History

You are strongly encouraged to run prefs_improve_reproducibility() after prefs_reset_to_defaults() to improve the reproducibility of your code.

prefs_improve_reproducibility()

About


Languages

Language:R 100.0%