Learn R Programming

path.chain (version 1.0.0)

as_config: Prepare list to be saved as config .yaml file

Description

This function is provided to keep compatibility with `{config}` package, which requires existence of default key. Additionally, we can at once wrap our structure with some other keys, in order to not to mix directory structure with different keys.

Usage

as_config(x, config = "default", wrap = "dirs", ...)

# S3 method for path_chain as_config(x, config = "default", wrap = "dirs", ..., root.name = "root.dir")

# S3 method for list as_config(x, config = "default", wrap = "dirs", ...)

Value

list compatible with `{config}` package

Arguments

x

list with directory structure

config

configuration name

wrap

key name to wrap directory structure

...

additional arguments (not used at the moment)

root.name

key for root directory (for path_chain only)

Examples

Run this code
library(magrittr)
# Initializing sample directory
tmp <- create_temp_dir("files")
create_sample_dir(tmp, override = TRUE)
full_path_chain(tmp, "kRoot", naming_k) %>%
   list(kDirs = .) %>%
   list(default = .) %>%
   yaml::write_yaml(temp_path("config.yaml"))
# We can simply use such function
full_path_chain(tmp, "kRoot", naming_k) %>%
   as_config("default", "kDirs") %>%
   yaml::write_yaml(temp_path("config.yaml"))

Run the code above in your browser using DataLab