Devtools: Handy function to reset options to defaults

Created on 26 Jul 2020  路  3Comments  路  Source: r-lib/devtools

Resetting options to their defaults can be a little cumbersome (I have just come from look around here, and here)

It could be useful to have something easily available, perhaps:

reset_options <- function() {
  default_opts <- callr::r(function(){options()})
  options(default_opts)
}

Note: there may already be easier/better ways of doing this. Apologies in advance if that's the case here

All 3 comments

You may want to consider using callr::r_vanilla() to do this, so that any options changed in your .Rprofile are not included.

But in general I don't think this function needs to be in devtools.

Base R should arguably expose the (default) options in some programmatic way. I've also often wanted a way to see the options "in force" and understand which are R defaults vs., say, set via an .Rprofile. Basically something like git config --list --show-origin. You @stevecondylios might consider opening an issue here: https://github.com/HenrikBengtsson/Wishlist-for-R/issues

Also, you should be aware of withr, which allows you to temporarily set options.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ctbrown picture ctbrown  路  4Comments

nick-youngblut picture nick-youngblut  路  6Comments

pssguy picture pssguy  路  5Comments

rz1988 picture rz1988  路  4Comments

hadley picture hadley  路  3Comments