Get the data belonging to a Data Resource
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)
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.
a dataresource
or datapackage
object.
passed on to the reader
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.
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"
.
the name of the dataresource
.
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
.
dp_get_connection
is a wrapper around
dp_get_data(..., as_connection = TRUE)
.