fetch_table: Send a table query and return the results

Description Usage Arguments Details Value

View source: R/fetch.R

Description

fetch_table sends a query to the table endpoint and returns the response as a list containing the results. The results include a dataframe of tidy data for each measure requested by the query.

Usage

1
fetch_table(query, filename = NULL, custom = NULL)

Arguments

query

Stat-Xplore query as a string.

filename

The path to a text file containing a Stat-Xplore query. This argument is not required but has priority: if a filename is provided, the query argument is ignored.

custom

A named list of character vectors. Each name/value pair indicates the item labels to use for the field with the given name when constructing the results dataframes. It is necessary to specify item labels explicitly using this argument when your query uses custom aggregate variables, as the number of variables in the results will not agree with the number of variables shown in the metadata.

Details

A query can be provided as a string or can be loaded from a file using the filename argument. This is sometimes convenient as Stat-Xplore queries can be large and are most easily produced using the table builder tool on the website, which exports queries as json text files.

Stat-Xplore returns one set of results for each measure included in a query. Each set of results includes data for different measures on the same set of observations.

The list of results has the following structure:

measures - the names of the measures for each dataset (character) fields - the names of categorical variables included in the data (character) items - the names of the categories or levels within each field (list) uris - the uris of the categories or levels within each field (list) dfs - a dataframe for each measure with the data in long form (list)

Value

A list containing the results of the query, with one item per cube.


houseofcommonslibrary/statxplorer documentation built on Sept. 13, 2020, 12:14 a.m.