Skip to contents

load_config() checks that the provided configfile is valid, and then loads its content into the movenet environment. This lets the movenet package know how to read and interpret upcoming input data files.

Usage

load_config(configfile)

Arguments

configfile

Either the path to a YAML-format movenet config file, or the name of a pre-installed config file in the movenet package's configurations folder.

Value

No return value, but load_config() has the effect of copying the provided configurations into the movenet environment. If this is successful, a message is printed.

Details

Values of configurations representing column headers or indices (in the config file fileopts section) are converted to ASCII-compliant and syntactically valid names before being loaded into in the environment.

See also

  • validate_config() for the underlying config file validation process.

  • asciify() for the underlying ASCIIfication process.

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

  • list.files(system.file("configurations", package = "movenet")) for a list of pre-installed templates and validated config files.

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

Other functions for initial data processing: asciify(), reformat_data()

Examples

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

# Load a config file using a path
load_config(system.file("configurations", "fakeScotEID_holding.yml", package="movenet"))
#> Successfully loaded config file: C:/Users/cboga/OneDrive - University of Glasgow/Documents/R/win-library/4.1/movenet/configurations/fakeScotEID_holding.yml
get_config() #Examine configurations
#> $holdingdata_fileopts.separator
#> [1] ","
#> 
#> $holdingdata_fileopts.encoding
#> [1] "UTF-8"
#> 
#> $holdingdata_fileopts.decimal
#> [1] "."
#> 
#> $holdingdata_fileopts.coord_EPSG_code
#> [1] 27700
#> 
#> $holdingdata_fileopts.country_code
#> [1] "UK"
#> 
#> $holdingdata_cols.id
#> [1] "cph"
#> 
#> $holdingdata_cols.coord_x
#> [1] "easting"
#> 
#> $holdingdata_cols.coord_y
#> [1] "northing"
#> 
#> $holdingdata_cols.type
#> [1] "holding_type"
#> 
#> $holdingdata_cols.herd_size
#> [1] "herd_size"
#> 

# Alternatively, load a pre-installed config file by using just its name
load_config("ScotEID.yml")
#> Successfully loaded config file: ScotEID.yml
get_config() #Examine configurations
#> $holdingdata_fileopts.separator
#> [1] ","
#> 
#> $holdingdata_fileopts.encoding
#> [1] "UTF-8"
#> 
#> $holdingdata_fileopts.decimal
#> [1] "."
#> 
#> $holdingdata_fileopts.coord_EPSG_code
#> [1] 27700
#> 
#> $holdingdata_fileopts.country_code
#> [1] "UK"
#> 
#> $holdingdata_cols.id
#> [1] "cph"
#> 
#> $holdingdata_cols.coord_x
#> [1] "easting"
#> 
#> $holdingdata_cols.coord_y
#> [1] "northing"
#> 
#> $holdingdata_cols.type
#> [1] "holding_type"
#> 
#> $holdingdata_cols.herd_size
#> [1] "herd_size"
#> 
#> $movedata_fileopts.separator
#> [1] ","
#> 
#> $movedata_fileopts.encoding
#> [1] "UTF-8"
#> 
#> $movedata_fileopts.decimal
#> [1] "."
#> 
#> $movedata_fileopts.date_format
#> [1] "%Y%m%d"
#> 
#> $movedata_cols.from
#> [1] "departure_cph"
#> 
#> $movedata_cols.to
#> [1] "dest_cph"
#> 
#> $movedata_cols.date
#> [1] "departure_date"
#> 
#> $movedata_cols.weight
#> [1] "qty_pigs"
#> 

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