raustats (version 0.1.0)

abs_stats: Download data from the ABS API

Description

This function downloads the specified ABS data series from the ABS API.

Usage

abs_stats(dataset, filter, start_date, end_date, lang = c("en", "fr"),
  dimensionAtObservation = c("AllDimensions", "TimeDimension",
  "MeasureDimension"), detail = c("Full", "DataOnly", "SeriesKeysOnly",
  "NoData"), enforce_api_limits = TRUE, return_url = FALSE,
  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.

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 <U+2013> and therefore groups <U+2013> 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)

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.

return_url

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

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.

Examples

Run this code
# NOT RUN {
  
# }
# NOT RUN {
    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);
 
# }

Run the code above in your browser using DataCamp Workspace