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.
Software Option Settings Manager for R. options_manager: Create a new options manager. reset_options: Reset general options in 'options' to factory defaults.
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.
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)
default_opts <- callr::r(function(){options()}); options(default_opts)
It works by starting a separate background process, accessing the default options within that session, and supplying the options back to the current session.
# 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With