Package: Data Package class

Description Usage Format Value Methods Properties Details Language Methods See Also

Description

A class for working with data packages. It provides various capabilities like loading local or remote data package, inferring a data package descriptor, saving a data package descriptor and many more.

Usage

1
# Package.load(descriptor = list(),basePath = NA,strict = FALSE)

Format

R6Class object

Value

Object of R6Class

Methods

Package$new(descriptor = list(),basePath = NA,strict = FALSE)

Use Package.load to instantiate Package class.

getResource(name)

Get data package resource by name or null if not found.

addResource(descriptor)

Add new resource to data package. The data package descriptor will be validated with newly added resource descriptor.

removeResource(name)

Remove data package resource by name. The data package descriptor will be validated after resource descriptor removal.

infer(pattern=FALSE)

Infer a data package metadata. If pattern is not provided only existent resources will be inferred (added metadata like encoding, profile etc). If pattern is provided new resoures with file names mathing the pattern will be added and inferred. It commits changes to data package instance.

commit(strict)

Update data package instance if there are in-place changes in the descriptor. Returns TRUE on success and FALSE if not modified.

save(target)

For now only descriptor will be saved. Save descriptor to target destination.

Properties

valid

Returns validation status. It always TRUE in strict mode.

errors

Returns validation errors. It always empty in strict mode.

profile

Returns an instance of Profile class.

descriptor

Returns list of package descriptor.

resources

Returns list of Resource instances.

resourceNames

Returns list of resource names.

Details

A Data Package consists of:

The Data Package metadata is stored in a "descriptor". This descriptor is what makes a collection of data a Data Package. The structure of this descriptor is the main content of the specification below.

In addition to this descriptor a data package will include other resources such as data files. The Data Package specification does NOT impose any requirements on their form or structure and can therefore be used for packaging any kind of data.

The data included in the package may be provided as:

Jsolite package is internally used to convert json data to list objects. The input parameters of functions could be json strings, files or lists and the outputs are in list format to easily further process your data in R environment and exported as desired. It is recommended to use helpers.from.json.to.list or helpers.from.list.to.json to convert json objects to lists and vice versa. More details about handling json you can see jsonlite documentation or vignettes here.

Language

The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this package documents are to be interpreted as described in RFC 2119.

Methods

Public methods


Method new()

Usage
Package$new(
  descriptor = list(),
  basePath = NULL,
  strict = FALSE,
  profile = NULL
)

Method addResource()

Usage
Package$addResource(descriptor)

Method getResource()

Usage
Package$getResource(name)

Method removeResource()

Usage
Package$removeResource(name)

Method infer()

Usage
Package$infer(pattern)

Method commit()

Usage
Package$commit(strict = NULL)

Method save()

Usage
Package$save(target, type = "json")

Method clone()

The objects of this class are cloneable with this method.

Usage
Package$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Package.load, Data Package Specifications


frictionlessdata/datapackage-r documentation built on Dec. 28, 2021, 8:42 a.m.