read_database: read_database

View source: R/read_database.R

read_databaseR Documentation

read_database

Description

Returns the data sets for the given reference - agencyid:id(version), as a list, or as a tidy data.table. A collection of data sets in econdatar is referred to as a database. Tidying can be done directly within read_database(), or ex-post using tidy_data().

Usage

read_database(id, include_series = FALSE, tidy = FALSE, ...)

## S3 method for class 'eds_database'
tidy_data(x, ...)

Arguments

id

Data set identifier. May be "all"

include_series

If TRUE series (and their metadata) with obervations omitted are included in the return (series are discarded when tidy is TRUE).

x

A raw API return object to be tidied. Can also be done directly in read_database() by setting tidy = TRUE

.

...

Further Optional arguments:

agencyid character. Defaults to ECONDATA. Agency responsible for the metadata creation/maintenance.
version character. Version(s) of the data (different versions will have different metadata), or "all" to return all available versions.
tidy

logical. Return data and metadata in tidy data.table's (see Value), by passing the result through tidy_data.

Details

An EconData account (http://econdata.co.za) is required to use this function. The user must provide an API token that can be found on the Account page of the online portal, a GUI dialog will prompt the user for their API token. Credentials can also be supplied by setting the ECONDATA_CREDENTIALS environment variable using the syntax: "client_id;client_secret", e.g. Sys.setenv(ECONDATA_CREDENTIALS="client_id;client_secret"), when available.

Value

If tidy = FALSE, an unnamed list of data frames is returned. Each data frame further has a "metadata" attribute providing information about the data set.

If tidy = TRUE a single data.table is returned with columns for "agencyid", "id", "version", "name", and "description".

See Also

write_database

Examples

## Not run: 
# library(econdatar)

# Mining production and sales
MINING <- read_database(id = "MINING")

# Include previous versions
MINING <- read_database(id = "MINING", versions = "all")

# Return series without obervations (empty data set)
MINING <- read_database(id = "MINING", include_series = TRUE)

# Return all data sets (useful for browsing available data)
CATALOGUE <- read_database(id = "all")
tidy_data(CATALOGUE)

## End(Not run)

coderaanalytics/econdatar documentation built on Nov. 1, 2024, 5:41 a.m.