as_path_chain {path.chain}R Documentation

Create chainable path

Description

This function always treats first object in the nested list as a subdirectory root path

Usage

as_path_chain(nested.list, root.name = "kRoot")

Arguments

nested.list

'list' object with nested lists/strings inside

root.name

key for root directory

Value

path_chain object

Examples

library(magrittr)
# Manually created nested list
nested.list <- list(kRoot = "root", "file1.txt", list("subdir", "file2.csv"))
chainable.path <- as_path_chain(nested.list)
class(chainable.path)
chainable.path$.
chainable.path$subdir$files2.csv
# Nested list from config file
tmp <- create_temp_dir("files")
create_sample_dir(tmp, override = TRUE)
fs::dir_tree(tmp)
path_chain(tmp, naming = naming_k) %>%
  as.list(root.name = "kRoot") %>%
  as_config("default", "kDirs") %>%
  yaml::write_yaml(temp_path("config.yaml"))
chainable.path <- config::get("kDirs", "defaul", temp_path("config.yaml")) %>%
 as_path_chain()
class(chainable.path)
chainable.path$.
chainable.path$kData$kExample1

[Package path.chain version 0.2.0 Index]