Skip to contents

change_config() allows the user to set the value of one or more configurations in the movenet environment. Any requested changes are validated before being made.

Usage

change_config(...)

Arguments

...

One or more configurations to change, using name = value format. These can be provided in the form of individual name-value pairs, as a named character vector, or as a named list.

Value

  • If one or more configuration name-value pairs are provided, a structured named list of the values of all configurations in the movenet environment, as they were before the function call (returned invisibly). As side effect, any provided configurations are changed in the movenet environment. If a configuration name is ambiguous or unrecognised, or if a requested change would result in an invalid configuration value, the requested configuration change is ignored and a warning is displayed.

  • If no arguments are provided, an unstructured named list of all configurations as currently set in the movenet environment.

Details

Configuration names

Each configuration name must follow the "datatype_configtype.configname" format, consisting of the following elements:

  • datatype: Type of data the configuration applies to. Either movedata or holdingdata.

  • configtype: Type of configuration. Either fileopts (file options) or cols (column headers/indices).

  • configname: Name of the specific configuration.

For example: "movedata_fileopts.separator", "holdingdata_cols.id"

change_config() uses partial matching for configuration names. If a configuration name is ambiguous or unrecognised (e.g. if the configuration is unset), the requested change is ignored and a warning is displayed.

Configuration values

Before configuration values are set, their data format is validated. Valid configuration data formats are as follows:

  • (move|holding)data_fileopts.separator: A single character.

  • (move|holding)data_fileopts.decimal: A single character.

  • (move|holding)data_fileopts.encoding: A character string.

  • (move|holding)data_fileopts.date_format: A character string matching readr date format specifications. See readr::parse_date() for guidance.

  • holdingdata_fileopts.country_code: A character string consisting of two upper-case letters.

  • holdingdata_fileopts.coord_EPSG_code: A single integer.

  • (move|holding)data_cols configurations: A character string or a single integer. All configurations within movedata_cols or holdingdata_cols must have unique values.

Configurations can't be set to NULL.

If a configuration value is invalid, the requested change is ignored and a warning is displayed.

See also

Other configurations-related functions: get_config(), load_config(), new_config(), save_config(), validate_config()

Examples

# Set-up: Save movenet environment with current configurations
movenetenv <- movenet:::movenetenv
old_config <- movenetenv$options

# Load a config file and examine current configurations
load_config(system.file("configurations", "fakeScotEID_holding.yml", package="movenet"))
#> Successfully loaded config file: C:/Users/cboga/AppData/Local/Temp/Rtmp25xhub/temp_libpath11484970381d/movenet/configurations/fakeScotEID_holding.yml
get_config("holdingdata_fileopts.separator", "holdingdata_cols.id") #Examine configurations
#> $holdingdata_fileopts.separator
#> [1] ","
#> 
#> $holdingdata_cols.id
#> [1] "cph"
#> 

# Change configurations
change_config(holdingdata_fileopts.sep = ".", holdingdata_cols.id = "identifier")
get_config("holdingdata_fileopts.separator", "holdingdata_cols.id") #Examine changed configurations
#> $holdingdata_fileopts.separator
#> [1] "."
#> 
#> $holdingdata_cols.id
#> [1] "identifier"
#> 

# Clean-up: Reinstate previous configurations
movenetenv$options <- old_config
rm("old_config", "movenetenv")