Learn R Programming

datapackage (version 0.2.0)

dp_get_data: Get the data belonging to a Data Resource

Description

Get the data belonging to a Data Resource

Usage

dp_get_data(x, ..., as_connection = FALSE)

# S3 method for dataresource dp_get_data(x, reader = "guess", ..., as_connection = FALSE)

# S3 method for datapackage dp_get_data(x, resource_name, reader = "guess", ..., as_connection = FALSE)

Value

Will return the data. This will generally be a data.frame but depending on the file type can also be other types of R-objects.

When called with the as_connection = TRUE argument, it will try to return a connection to the data. This depends on the reader. When the reader does not support returning connections it will return the data.

Arguments

x

a dataresource or datapackage object.

...

passed on to the reader

as_connection

Try to return a connection to the data instead of the data itself. When a reader does not support returning connections it will return the data.

reader

the reader to use to read the data. This should be either a function accepting the path to the data set (a character vector with possibly multitple filenames) and the Data Resource as second argument, or the character string "guess".

resource_name

the name of the dataresource.

Details

When reader = "guess" the function will try to guess which reader to use based on the format and mediatype of the Data Resource. Currently only CSV is supported. For other data types a custom reader has to be provided unless the data is stored inside the Data Resource object.

It is also possible to assign default readers for data formats. For that see dp_add_reader.

See Also

dp_get_connection is a wrapper around dp_get_data(..., as_connection = TRUE).