Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reset all options() arguments to their default values?

Tags:

r

settings

As noted in the title, I'm trying to understand how to reset all arguments in options() to their default settings. I searched online and in the ?options help file and am failing to locate an answer.

I expect the answer is readily available, and I'm simply struggling to find it.

Thanks.

Edit: While I agree How to set R to default options? is the same question, I'm failing to see in its selected answer the clear/explicit solution I requested: how to reset options() to its defaults. The selected answer in that thread clearly explains how to save options() settings and load them later.

like image 860
Daniel Fletcher Avatar asked Apr 25 '16 18:04

Daniel Fletcher


People also ask

How do I reset my options in R?

Software Option Settings Manager for R. options_manager: Create a new options manager. reset_options: Reset general options in 'options' to factory defaults.

How do you return tool settings to their default values?

For most tools, if you right click on one of the tools input fields, the popup menu should show "Reset All to Default" as an option.


2 Answers

If you restart your R session, it will reset the options to the default values. Options are saved in a list, and calling options() will show that list.

You can save the default options after restarting R:

backup_options <- options()

You can make any changes you need, and then to revert to the default options:

options(backup_options)

like image 126
ano Avatar answered Oct 20 '22 17:10

ano


Simply run this:

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

How it works

It works by starting a separate background process, accessing the default options within that session, and supplying the options back to the current session.

Example

# Default option
options("scipen")
# $scipen
# [1] 0

# Set to something else
options(scipen = 999)
# $scipen
# [1] 999

# Reset to defaults:
default_opts <- callr::r(function(){options()}); options(default_opts)

# Option is back to its default value
options("scipen")
# $scipen
# [1] 0
like image 37
stevec Avatar answered Oct 20 '22 18:10

stevec