Adds documentation of a dataset to a datapackage
Source:R/dcf_datapackage_add.R
dcf_datapackage_add.RdAdd information about variables in a dataset to a datapackage.json metadata file.
Usage
dcf_datapackage_add(
filename,
meta = list(),
packagename = "datapackage.json",
dir = ".",
write = TRUE,
refresh = TRUE,
sha = "512",
pretty = FALSE,
summarize_ids = FALSE,
open_after = FALSE,
verbose = interactive()
)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
.jsonfile relative todir, or a list with the read-in version.- dir
Directory in which to look for
filename, and writepackagename.- write
Logical; if
FALSE, returns thepathsmetadata without reading or rewritingpackagename.- refresh
Logical; if
FALSE, will retain any existing dataset information.- sha
A number specifying the Secure Hash Algorithm function, if
opensslis available (checked withSys.which('openssl')).- pretty
Logical; if
TRUE, will pretty-print the datapackage.- summarize_ids
Logical; if
TRUE, will include ID columns in schema field summaries.- open_after
Logical; if
TRUE, opens the written datapackage after saving.- verbose
Logical; if
FALSE, will not show status messages.
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 forurl.- ids
A list or list of lists with entries for at least
variable(the name of a variable in the dataset). Might also includemapwith 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 as map 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
dcf_measure_info.- vintage
A string specifying the time and/or location at which the data were produced.
See also
Initialize the datapackage.json file with dcf_datapackage_init.
Examples
if (FALSE) { # \dontrun{
# write example data
write.csv(mtcars, "mtcars.csv")
# add it to an existing datapackage.json file in the current working directory
dcf_datapackage_add("mtcars.csv")
} # }