dpgetdata: Get the data belonging to a Data Resource

View source: R/dpgetdata.R

dpgetdataR Documentation

Get the data belonging to a Data Resource

Description

Get the data belonging to a Data Resource

Usage

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

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

## S3 method for class 'datapackage'
dpgetdata(x, resourcename, reader = "guess", ..., as_connection = FALSE)

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".

resourcename

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 dpaddreader.

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.

See Also

dpgetconnection is a wrapper around dpgetdata(..., as_connection = TRUE).


djvanderlaan/datapackage documentation built on March 18, 2024, 4:57 p.m.