View source: R/package_update.R
package_update | R Documentation |
This function updates all package metadata fields. Any update will also set the metadata key "last_updated". Any omitted metadata fields will be overwritten.
package_update(
x,
id,
http_method = "GET",
url = get_default_url(),
key = get_default_key(),
as = "list",
...
)
x |
(list) A list with key-value pairs |
id |
(character) Package identifier |
http_method |
(character) which HTTP method (verb) to use; one of "GET" or "POST". Default: "GET" |
url |
Base url to use. Default: https://data.ontario.ca/ See
also |
key |
A privileged CKAN API key, Default: your key set with
|
as |
(character) One of list (default), table, or json. Parsing with
table option uses |
... |
Curl args passed on to |
## Not run:
# Setup
ckanr_setup(url = "https://demo.ckan.org/", key = getOption("ckan_demo_key"))
# Step 1: get the dataset details as R list
ds_id <- "my-dataset-id-md5-hash"
ds <- ckanr::package_show(ds_id, as="table")
# Step 2: update selected fields
ds$title <- "An updated title"
ds$description <- "Only title and description have been updated."
ds contains all other package data, including tags and resources
# Step 3a: Update the dataset on CKAN with locally modified metadata `ds`
result <- ckanr::package_update(ds, ds_id)
# Replace existing package metadata
# Step 3b: Possible or intended data loss
# Any metadata fields missing from `ds` will be deleted in the package
del(ds$description)
result_with_deleted_description <- ckanr::package_update(ds, ds_id)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.