Skip to contents

Solver paths and other options can be persisted to a YAML file so they are restored in every session: the user-wide file under tools::R_user_dir()("energyRt", "config"), or ./.energyRt.yml for a single project. energyRt applies them when the package loads, without overriding anything the user has already set through an R option or an environment variable.

Use en_config_show() to see which options are in effect and where each value came from.

en_config_read() reads the project config (./.energyRt.yml) merged over the user-wide one. It reports what is on disk; use en_config_show() for what is actually in effect.

en_config_write() persists options so they are restored in later sessions. Called with no arguments it writes every option whose current value differs from the package default – so the usual workflow is to set paths interactively, check them with en_config_show(), then call en_config_write() once.

Usage

en_config_path(global = TRUE)

en_config_read(global = NULL)

en_config_write(config = NULL, global = TRUE, backup = TRUE)

Arguments

global

logical. TRUE writes the user-wide config (see en_config_path()), FALSE writes ./.energyRt.yml.

config

named list of option values, using names without the en. prefix (e.g. list(gams_path = "C:/GAMS/48")). NULL (default) collects the currently non-default options.

backup

logical. When writing the user-wide config, move any pre-0.74 files in the home directory (~/.energyRt/config.yml and the deprecated ~/.energyRt.R) aside to *.bak. They would otherwise keep overriding the new config. Set FALSE to leave them in place.

Value

character, the path. The file need not exist.

a named list of option values, possibly empty.

the written config, invisibly.

Location

Up to energyRt 0.74 the user-wide file was ~/.energyRt/config.yml. CRAN policy does not allow a package to write in the user's home filespace, so it now lives in the standard R user configuration directory instead. The old file is still read (nothing breaks), and en_config_write() moves it aside once the new one exists.

Examples

en_config_path()
#> [1] "C:\\Users\\admin\\AppData\\Roaming/R/config/R/energyRt/config.yml"
if (FALSE) { # \dontrun{
set_solver_path("gams", "C:/GAMS/win64/48.1")
en_config_write()
} # }