datapackage_init: Initialise a data package from a data frame, metadata list,...

Description Usage Arguments Examples

Description

Initialise a data package from a data frame, metadata list, and source code file used to create the data set.

Usage

1
2
datapackage_init(df, package_name = NULL, output_dir = getwd(),
  meta = NULL, source_cleaner = NULL, source_cleaner_rename = TRUE, ...)

Arguments

df

The object name of the data frame you would like to convert into a data package.

package_name

character string name for the data package. Unnecessary if the name field is specified in meta.

output_dir

character string naming the output directory to save the data package into. By default the current working directory is used.

meta

The list object with the data frame's meta data. The list item names must conform to the Open Knowledge Foundation's Data Package Protocol (see http://dataprotocols.org/data-packages/). Must include the name, license, and version fields. If resources is not specified then this will be automatically generated. dpmr uses jsonlite to convert the list into a JSON file. See the toJSON documentation for details. If meta = NULL then a barebones datapackage.json file will be created.

source_cleaner

a character string or vector of file paths relative to the current working directory pointing to the source code file used to gather and clean the df data frame. Can be in R or any other language, e.g. Python. Following Data Package convention the scripts are renamed process*.*, unless specified otherwise with source_cleaner_rename. source_cleaner is not required, but HIGHLY RECOMMENDED.

source_cleaner_rename

logical. Whether or not to rename the source_cleaner files.

...

arguments to pass to export.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Not run: 
# Create fake data
A <- B <- C <- sample(1:20, size = 20, replace = TRUE)
ID <- sort(rep('a', 20))
Data <- data.frame(ID, A, B, C)

# Initialise data package with barebones, automatically generated metadata
datapackage_init(df = Data, package_name = 'my-data-package')

# Initialise with user specified metadata
meta_list <- list(name = 'my-data-package',
                 title = 'A fake data package',
                 last_updated = Sys.Date(),
                 version = '0.1',
                 license = data.frame(type = 'PDDL-1.0',
                          url = 'http://opendatacommons.org/licenses/pddl/'),
                 sources = data.frame(name = 'Fake',
                          web = 'No URL, its fake.'))

 datapackage_init(df = Data, meta = meta_list)

## End(Not run)

christophergandrud/dpmr documentation built on May 13, 2019, 7:02 p.m.