Skip to contents

save_config() saves the configurations currently set in the movenet environment to a new config file of the type indicated by config_type.

Usage

save_config(outfile, config_type = c("movement", "holding"))

Arguments

outfile

The name and path of the file to which the configurations will be saved.

config_type

Character vector representing the type of configurations to save: one of c("movement", "holding") (default, resulting in a combined config file), "movement" or "holding".

Value

No return value, but save_config() has the effect of writing a YAML-format config file containing (a subset of) the configurations found in the movenet environment. If this is successful, a message is printed.

Details

N.B.: The resulting config file is not automatically validated.

See also

vignette("configurations") for an explanation of the movenet config system.

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

Examples

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

# Load a config file
load_config(system.file("configurations", "ScotEID.yml", package="movenet"))
#> Successfully loaded config file: C:/Users/cboga/OneDrive - University of Glasgow/Documents/R/win-library/4.1/movenet/configurations/ScotEID.yml

# Save the currently loaded movement configurations to a new config file in `tempdir()`
save_config(paste0(tempdir(),"\\saved_movement_config.yml"), "movement")
#> Successfully saved movement configurations to: C:\Users\cboga\AppData\Local\Temp\RtmpcFucP4\saved_movement_config.yml

#Examine file contents
xfun::file_string(paste0(tempdir(),"\\saved_movement_config.yml"))
#> movedata_fileopts:
#>   separator: ','
#>   encoding: UTF-8
#>   decimal: '.'
#>   date_format: '%Y%m%d'
#> movedata_cols:
#>   from: departure_cph
#>   to: dest_cph
#>   date: departure_date
#>   weight: qty_pigs

# Clean-up: Remove the saved file and reinstate previous configurations
file.remove(paste0(tempdir(),"\\saved_movement_config.yml"))
#> [1] TRUE
movenetenv$options <- old_config
rm("old_config", "movenetenv")