dpaddreader | R Documentation |
Add a reader function for a specific format
dpaddreader(
format,
reader,
mediatypes = character(0),
extensions = character(0)
)
format |
the data format read by the reader. Should be a length 1 character vector. |
reader |
the reader function. See details. |
mediatypes |
a character vector with the media-types that are used for the format. |
extensions |
a character vector with typical file extensions used by the format. |
Adds a reader for a given format. The reader is added to a list of reades
references by the format. It is also possible to assign mediatypes and file
extensions to the format. When the format for a given Data Resource is
missing, dpgetdata
will first check if a mediatype is
associated with the resource and will try to look up which format belongs to
the fiven mediatype. If that doesn't result in a valid format,
dpgetdata
will try the same with the extension of the file.
Note that adding a reader for an existing format will overwrite the existing reader.
Does not return anything (invisible(NULL)
).
# Add a very simple reader for json
json_reader <- function(path, resource, ...) {
lapply(path, function(fn) {
jsonlite::read_json(fn)
})
}
dpaddreader("json", json_reader, c("application/json"), "json")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.