abs_stats: Download data from the ABS API

Description Usage Arguments Value Note Author(s) Examples

View source: R/abs-api-functions.R

Description

This function queries and returns data for a specified ABS dataset from the ABS API.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
abs_stats(
  dataset,
  filter,
  start_date,
  end_date,
  lang = c("en", "fr"),
  dimensionAtObservation = c("AllDimensions", "TimeDimension", "MeasureDimension"),
  detail = c("Full", "DataOnly", "SeriesKeysOnly", "NoData"),
  return_json = FALSE,
  return_url = FALSE,
  enforce_api_limits = TRUE,
  update_cache = FALSE
)

Arguments

dataset

Character vector of ABS.Stat dataset codes. These codes correspond to the indicatorID column from the indicator data frame of abs_cache or abs_cachelist, or the result of abs_indicators.

filter

A list that contains filter of dimensions available in the specified series to use in the API call. If NULL, no filter is set and the query tries to return all dimensions of the dataset. Valid dimensions to include in the list supplied to filter include: MEASURE, REGION, INDEX, TSEST and FREQUENCY.

start_date

Numeric or character. If numeric it must be in year). For data at the sub-annual granularity the API supports a format as follows: Monthly data – '2016-M01', Quarterly data – '2016-Q1', Semi-annual data – '2016-B2', Financial year data – '2016-17'.

end_date

Numeric or character (refer to startdate).

lang

Language in which to return the results. If lang is unspecified, english is the default. ## @param remove_na If TRUE, remove blank or NA observations. If FALSE, no blank or NA ## values are removed from the return. ## @param include_unit If TRUE, the column unit is not removed from the return. If ## FALSE, this column is removed. ## @param include_obsStatus If TRUE, the column obsStatus is not removed from the return. If ## FALSE, this column is removed.

dimensionAtObservation

The identifier of the dimension to be attached at the observation level. The default order is: 'AllDimensions', 'TimeDimension' and 'MeasureDimension'. AllDimensions results in a flat list of observations without any grouping.

detail

This argument specifies the desired amount of information to be returned. Possible values are:

  • Full: all data and documentation, including annotations (default)

  • DataOnly: attributes <e2><80><93> and therefore groups <e2><80><93> will be excluded

  • SeriesKeysOnly: only the series elements and the dimensions that make up the series keys

  • NoData: returns the groups and series, including attributes and annotations, without observations (all values = NA)

return_json

Logical. Default is FALSE. If TRUE, the function returns the result in raw sdmx-json.

return_url

Default is FALSE. If TRUE, the function returns the generated request URL and does not submit the request.

enforce_api_limits

If TRUE (the default), the function enforces the ABS.Stat RESTful API limits and will not submit the query if the URL string length exceeds 1000 characters or the query would return more than 1 million records. If FALSE, the function submits the API call regardless and attempts to return the results.

update_cache

Logical expression, if FALSE (default), use the cached list of available ABS.Stat datasets, if TRUE, update the list of available datasets.

Value

Returns a data frame of the selected series from the specified ABS dataset.

Note

The data query submitted by this function uses the ABS RESTful API based on the SDMX-JSON standard. It has a maximum allowable character limit of 1000 characters allowed in the data URL.

Further limitations known at this time include:

Author(s)

David Mitchell <david.pk.mitchell@gmail.com>

Examples

1
2
3
4
5
6
7
8
9
  
    x <- abs_stats(dataset="CPI", filter="all", return_url=TRUE);
    x <- abs_stats(dataset="CPI", filter=list(MEASURE=1, REGION=c(1:8,50),
                                              INDEX=10001, TSEST=10, FREQUENCY="Q"));
    x <- abs_stats(dataset="CPI", filter=list(MEASURE="all", REGION=50,
                                              INDEX=10001, TSEST=10, FREQUENCY="Q"));
    x <- abs_stats(dataset="CPI", filter=list(MEASURE="all", REGION=50, INDEX=10001,
                                              TSEST=10, FREQUENCY="Q"), return_url=TRUE);
 

raustats documentation built on Jan. 11, 2020, 9:31 a.m.