ckanr (version 0.3.0)

ds_create: Add a new table to a datastore

Description

BEWARE: This function still doesn't quite work yet.

Usage

ds_create(resource_id = NULL, resource = NULL, force = FALSE,
  aliases = NULL, fields = NULL, records = NULL,
  primary_key = NULL, indexes = NULL, url = get_default_url(),
  key = get_default_key(), as = "list", ...)

Arguments

resource_id

(string) Resource id that the data is going to be stored against.

resource

(dictionary) Resource dictionary that is passed to resource_create(). Use instead of resource_id (optional)

force

(logical) Set to TRUE to edit a read-only resource. Default: FALSE

aliases

(character) Names for read only aliases of the resource. (optional)

fields

(list) Fields/columns and their extra metadata. (optional)

records

(list) The data, eg: [{"dob": "2005", "some_stuff": ["a", "b"]}] (optional)

primary_key

(character) Fields that represent a unique key (optional)

indexes

(character) Indexes on table (optional)

url

Base url to use. Default: http://data.techno-science.ca. See also ckanr_setup and get_default_url.

key

A privileged CKAN API key, Default: your key set with ckanr_setup

as

(character) One of list (default), table, or json. Parsing with table option uses jsonlite::fromJSON(..., simplifyDataFrame = TRUE), which attempts to parse data to data.frame's when possible, so the result can vary from a vector, list or data.frame. (required)

...

Curl args passed on to POST (optional)

References

http://bit.ly/1G9cnBl

Examples

Run this code
# NOT RUN {
# create a package
(res <- package_create("foobarrrr", author="Jane Doe"))

# then create a resource
file <- system.file("examples", "actinidiaceae.csv", package = "ckanr")
(xx <- resource_create(package_id = res$id,
                       description = "my resource",
                       name = "bears",
                       upload = file,
                       rcurl = "http://google.com"
))
ds_create(resource_id = "f4129802-22aa-4437-b9f9-8a8f3b7b2a53",
         records = iris, force = TRUE, key = "my-api-key")
# }

Run the code above in your browser using DataLab