as_config {path.chain} | R Documentation |
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.
as_config(x, config = "default", wrap = "dirs", ...)
## S3 method for class 'path_chain'
as_config(x, config = "default", wrap = "dirs", ..., root.name = "root.dir")
## S3 method for class 'list'
as_config(x, config = "default", wrap = "dirs", ...)
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) |
list compatible with '{config}' package
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"))