yaml: Edit DataPackageR yaml configuration

Description Usage Arguments Details Value Examples

Description

Edit a yaml configuration file via an API.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
yml_find(path)

yml_add_files(config, filenames)

yml_disable_compile(config, filenames)

yml_enable_compile(config, filenames)

yml_add_objects(config, objects)

yml_list_objects(config)

yml_list_files(config)

yml_remove_objects(config, objects)

yml_remove_files(config, filenames)

yml_write(config, path = NULL)

Arguments

path

Path to the data package source or path to write config file (for yml_write)

config

an R representation of the datapackager.yml config, returned by yml_find, or a path to the package root.

filenames

A vector of filenames.

objects

A vector of R object names.

Details

Add, remove files and objects, enable or disable parsing of specific files, list objects or files in a yaml config, or write a config back to a package.

Value

A yaml configuration structured as an R nested list.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
if(rmarkdown::pandoc_available()){
f <- tempdir()
f <- file.path(f,"foo.Rmd")
con <- file(f)
writeLines("```{r}\n tbl = table(sample(1:10,1000,replace=TRUE)) \n```\n",con=con)
close(con)
pname <- basename(tempfile())
datapackage_skeleton(name=pname,
   path = tempdir(),
   force = TRUE,
   r_object_names = "tbl",
   code_files = f)
yml <- yml_find(file.path(tempdir(),pname))
cat(yaml::as.yaml(yml))
yml <- yml_add_files(yml,"foo.Rmd")
yml_list_files(yml)
yml <- yml_disable_compile(yml,"foo.Rmd")
cat(yaml::as.yaml(yml))
yml <- yml_enable_compile(yml,"foo.Rmd")
cat(yaml::as.yaml(yml))
yml <- yml_add_objects(yml,"data1")
yml_list_objects(yml)
yml <- yml_remove_objects(yml,"data1")
yml <- yml_remove_files(yml,"foo.Rmd")
}

DataPackageR documentation built on March 17, 2021, 5:07 p.m.