Learn R Programming

datapackage (version 0.2.0)

dp_generate_dataresource: Generate Data Resource for a dataset

Description

Generate Data Resource for a dataset

Usage

dp_generate_dataresource(
  x,
  name,
  path = paste0(name, getextension(format)),
  format = "csv",
  mediatype = getmediatype(format),
  use_existing = FALSE,
  categories_type = c("regular", "resource"),
  categorieslist = iscategorieslist(x),
  ...
)

Value

Returns a Data Resource object.

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

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

use_existing

use existing field descriptors if present.

categories_type

how should categories be stored. See dp_generate_fielddescriptor.

categorieslist

does the data resource function as a categories list for fields in another data resource

...

Currently ignored

Examples

Run this code
# generate an example dataset
dta <- data.frame(a = 1:3, b = factor(letters[1:3]))
resource <- dp_generate_dataresource(dta, "example")
print(resource)

Run the code above in your browser using DataLab