Data package builds are controlled using the
This file is created in the package source tree when the user creates a package using
It is automatically populated with the names of the
data_objects the passed in to datapackage_skeleton.
The structure of a correctly formatted
datapackager.yml file is shown below:
library(DataPackageR) library(yaml) yml <- DataPackageR::construct_yml_config(code = "subsetCars.Rmd", data = "cars_over_20")
The main section of the file is the
It has three properties:
The files (
Rmd) to be processed by DataPackageR. They are processed in the order shown. Users running multi-script workflows with dependencies between the scripts need to ensure the files are processed in the correct order.
subsetCars.Rmd is the only file to process. The name is transformed to an absolute path within the package.
Each file itself has just one property:
no flag indicating whether the file should be rendered during the build, or whether it should be skipped.
This is useful for 'turning off' long running processing tasks if they have not changed. Disabling processing of a file will not overwrite existing documentation or data objecs created during previous builds.
The names of the data objects created by the processing files, to be stored in the package. These names are compared against the objects created in the render environment by each file. They names must match.
The directory where the
R files will be rendered. Defaults to a randomly named subdirectory of
tempdir(). Allows workflows that use multiple scripts and create file system artifacts to function correctly by simply writing to and reading from the working directory.
The structure of the YAML is simple enough to understand but complex enough that it can be a pain to edit by hand.
DataPackageR provides a number of API calls to construct, read, modify, and write the yaml config file.
Make an r object representing a YAML config file.
The YAML config shown above was created by:
# Note this is done by the datapackage_skeleton. # The user doesn't usually need to call # construct_yml_config() yml <- DataPackageR::construct_yml_config( code = "subsetCars.Rmd", data = "cars_over_20" )
Read a yaml config file from a package path into an r object.
Read the YAML config file from the
# returns an r object representation of # the config file. mtcars20_config <- yml_find( file.path(tempdir(),"mtcars20") )
objects in a config read by
files in a config read by
Disable compilation of named files in a config read by
yml_disabled <- yml_disable_compile( yml, filenames = "subsetCars.Rmd") cat(as.yaml(yml_disabled))
Enable compilation of named files in a config read by
yml_enabled <- yml_enable_compile( yml, filenames = "subsetCars.Rmd") cat(as.yaml(yml_enabled))
Add named files to a config read by
yml_twofiles <- yml_add_files( yml, filenames = "anotherFile.Rmd") # cat(as.yaml(yml_twofiles))
Add named objects to a config read by
yml_twoobj <- yml_add_objects( yml_twofiles, objects = "another_object") # cat(as.yaml(yml_twoobj))
Remove named files from a config read by
yml_twoobj <- yml_remove_files( yml_twoobj, filenames = "anotherFile.Rmd") # cat(as.yaml(yml_twoobj))
Remove named objects from a config read by
yml_oneobj <- yml_remove_objects( yml_twoobj, objects = "another_object") # cat(as.yaml(yml_oneobj))
Write a modified config to its package path.
yml_write(yml_oneobj, path = "path_to_package")
yml_oneobj read by
yml_find() carries an attribute
that is the path to the package. The user doesn't need to pass a
yml_write if the config has been read by
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.