write_attributes: Create a template yaml file for supplying attribute metadata...

View source: R/write_attributes.R

write_attributesR Documentation

Create a template yaml file for supplying attribute metadata for a tabular data object

Description

write_attributes creates a template as a yaml file for supplying attribute metadata for a tabular data object that resides in the R environment.

Usage

write_attributes(dfname, overwrite = FALSE, return_type = "yaml")

Arguments

dfname

(character) The quoted or unquoted name of the data object (data frame, tibble, simple feature).

overwrite

(logical) Logical indicating if an existing attributes file in the target directory should be overwritten.

return_type

(character) Quoted designator indicating the value returned as either a attributes template yaml file (return_type = "yaml", the default) or a list of entity attributes (return_type = "attributes") constructed from the data entity, the latter primarily as a helper feature for updating an existing attributes file.

Details

The yaml template generated by write_attributes includes the field names of the data entity. The number type, column class (e.g., factor, numeric), minimum and maximum values (if numeric), and missing value code and explanation (if provided) for each field. The template supports input of format string, unit, definition, and attribute definition. The yaml file is written with the name of the data object in R + "_attrs". The create_dataTable function will search for this file will creating a EML dataTable entity.

Value

The name of the file generated is returned, and a template for providing attribute metadata as a yaml file with the file name of the R data object + "_attrs.yaml" is created in the working directory.

Examples

## Not run: 

 # create attributes file for mycars data object, overwriting an existing
 # file if one exists

 mycars <- head(mtcars)

 capeml::write_attributes(
   dfname    = mycars,
   overwrite = TRUE
 )


## End(Not run)


CAPLTER/capeml documentation built on Oct. 1, 2024, 7:38 a.m.