dpgeneratedataresources: Generate Data Resources for a dataset

View source: R/dpgeneratedataresources.R

dpgeneratedataresourcesR Documentation

Generate Data Resources for a dataset

Description

Generate Data Resources for a dataset

Usage

dpgeneratedataresources(
  x,
  name,
  path = paste0(name, getextension(format)),
  format = "csv",
  mediatype = getmediatype(format),
  format_codelists = format,
  mediatype_codelists = getmediatype(format_codelists),
  ...
)

Arguments

x

data.frame for which to generate the Data Resources.

name

name of the Data Resource

path

name of the file in which to store the dataset. This should be a path relative to the location of the directory in which the Data Package in which the Data Resource will be stored.

format

the data format in which the data is stored.

mediatype

mediatype of the data

format_codelists

data format to use for the code lists

mediatype_codelists

mediatyp of the code lists

...

Currently ignored

Value

Returns a list with Data Resource objects. The first Data Resource is that of the dataset x itself. Additional Data Resources are for the code lists of the variables. Code lists are generated for fields that have a code list and for factor variables.

Note that this function does not create the file at path. The export of the Data Resource is automatically set to CSV.

Examples

# generate an example dataset
dta <- data.frame(a = 1:3, b = factor(letters[1:3]))
resources <- dpgeneratedataresources(dta, "example")
print(resources)


djvanderlaan/datapackage documentation built on March 18, 2024, 4:57 p.m.