Skip to contents

Add information about variables in a dataset to a datapackage.json metadata file.

Usage

data_add(filename, meta = list(), packagename = "datapackage.json",
  dir = ".", write = TRUE, refresh = TRUE, sha = "512",
  clean = FALSE, open_after = FALSE)

Arguments

filename

A character vector of paths to plain-text tabular data files, relative to dir.

meta

Information about each data file. A list with a list entry for each entry in filename; see details. If a single list is provided for multiple data files, it will apply to all.

packagename

Package to add the metadata to; path to the .json file relative to dir, or a list with the read-in version.

dir

Directory in which to look for filename, and write packagename.

write

Logical; if FALSE, returns the paths metadata without reading or rewriting packagename.

refresh

Logical; if FALSE, will retain any existing dataset information.

sha

A number specifying the Secure Hash Algorithm function, if openssl is available (checked with Sys.which('openssl')).

clean

Logical; if TRUE, strips special characters before saving.

open_after

Logical; if TRUE, opens the written datapackage after saving.

Value

An invisible version of the updated datapackage, which is also written to datapackage.json if write = TRUE.

Details

meta should be a list with unnamed entries for entry in filename, and each entry can include a named entry for any of these:

source

A list or list of lists with entries for at least name, and ideally for url.

ids

A list or list of lists with entries for at least variable (the name of a variable in the dataset). Might also include map with a list or path to a JSON file resulting in a list with an entry for each ID, and additional information about that entity, to be read in a its features. All files will be loaded to help with aggregation, but local files will be included in the datapackage, whereas hosted files will be loaded client-side.

time

A string giving the name of a variable in the dataset representing a repeated observation of the same entity.

variables

A list with named entries providing more information about the variables in the dataset. See data_measure_info.

See also

Initialize the datapackage.json file with init_data.

Examples

if (FALSE) {
# write example data
write.csv(mtcars, "mtcars.csv")

# add it to an existing datapackage.json file in the current working directory
data_add("mtcars.csv")
}