Skip to contents

data() is a convenience function that searches the database and returns

  1. search results if multiple matching tables are found, and

  2. data if only one match is found.

data_get() returns data without performing searching or pattern filters. In production code it is better to use data_get() instead of data() as it slightly faster and does not depend on the search mechanism. data_get() will result in error, if no match exists.

data_search() only performs a search and returns the results.

Usage

dаta(
  pattern = "",
  dl_filter = NULL,
  labels = getOption("robonomistClient.labels"),
  lang = NULL,
  na.rm = FALSE,
  tidy_time = getOption("robonomistClient.tidy_time"),
  ...
 )

data_get(
  id,
  dl_filter = NULL,
  labels = getOption("robonomistClient.labels"),
  lang = NULL,
  na.rm = FALSE,
  tidy_time = getOption("robonomistClient.tidy_time"),
  ...
)

data_search(pattern = "")

Arguments

pattern

string, Search query or table id, possibly followed by a §-filter.

dl_filter

list or named vector passed to datasource download functions for filtering incoming data. Supported by tulli, OECD and ECB.

labels

logical, Some datasources can return labelled or coded data.

lang

Two-letter language code, e.g. "en" or "sv".

na.rm

Px-file based datasources return a table with a combination of all categories. Missing values can be filtered when reading the file to improve preformance.

tidy_time

logical, If TRUE, the time dimension is parsed into Date class and renamed time. If NULL, the datasource specific default will be used.

...

Datasource-specific arguments. TODO

id,

string, Exact robonomist_id

§-filter

The data() function allows for a special §-filter. When the pattern matches a single table and the function returns a data frame, the §-filter can be used to subset rows of data frame. The tibble is filterd by sequence of regular expressions separated by section sign §. The regular expression are applied to data frame's variables sequentially.

If the last variable is a date, it is used as a start date filter.

Download filter

Some datasources (e.g. datasets "ecb" & "tulli") do not allow downloading full data tables, nor is it always preferred due to the large large size of table. For these datasources the user must provide a download filter via the dl_filter argument. When the argument is left as NULL, the data function will return a list of variables and potential values. This list can be used to construct a suitable download filter.

Generally, dl_filter should be named list where names are variable names and values character vectors of selected values (see Examples). Alternatively, some datasources allow for a dot-separated string to define a download filter.

Examples

if (FALSE) { # \dontrun{
## Return information on the data table structure
data("ecb/AME")
## Example of download filter
data("ecb/AME", dl_filter = list(ame_ref_area = "FIN"))

data(
  "ecb/FM",
  dl_filter = list(
    freq = "M",
    provider_fm_id = "EURIBOR1YD_"
  )
)
data("ecb/FM", dl_filter = "M.U2.EUR.RT.MM.EURIBOR1YD_.HSTA")

data("tulli/uljas_cpa2008",
  dl_filter = list(
    "Tavaraluokitus CPA2008_2" = "*A-X",
    "Aika" = c("201505", "201506"),
    "Maa" = "=ALL",
    "Suunta" = "=FIRST 1",
    "Indikaattorit" = "=FIRST 1"
  )
)
} # }