Learn R Programming

restatis

restatis is a wrapper around the RESTful API that provides access to the three main databases of German official statistics:

All functions work on either one of them, on all of them or just on a selection.

Installation

You can install the released version of {restatis} from CRAN:

install.packages("restatis")

Or install the development version of {restatis} from GitHub with:

# install.packages("devtools")
devtools::install_github("CorrelAid/restatis")

Usage

Authentication

To access each one of the APIs, you need to have an account that you can create on the homepage (see links to them above) and store your username and password for use in R with restatis::gen_auth_save() (see ?gen_auth_save for more details). The Zensus 2022 database does support authentication with an API token as well.

Main features

{restatis} provides functions (prefixed with gen_) for finding, exploring, and retrieving data from the three supported APIs. See the “Basic restatis workflow” vignette for an overview of the main features of the package.

In a short overview, there are functions divided in two main parts, searching for (meta)data and retrieving data:

Searching for (meta)data

  • gen_catalogue(): Search the API’s catalogue of data
  • gen_find(): Find objects related to a search term
  • gen_metadata(): Find meta data to an objects
  • gen_alternative_terms(): Find alternative terms to a search term
  • gen_modified_data(): Find out when an object has last been modified
  • gen_objects2stat(), gen_objects2var(), gen_var2stat(), gen_val2var(), gen_val2var2stat() and gen_search_vars(): Find objects, statistics, variables and values related to each other

Retrieving data

  • gen_cube(): Using this function, you can download ‘cube’ objects
  • gen_table(): Using this function, you can download ‘table’ objects
  • gen_list_jobs() and gen_download_job(): Using this function, you can find and download previously created jobs (large tables)

Other functions

  • gen_logincheck(): Perform a logincheck to test your credentials
  • gen_qualitysigns(): Get a list of quality signs (special characters) found in the API’s tables
  • gen_update_evas(): Manually scrape a newer version of the EVAS numbers (official statistic IDs)

Caching

{restatis} uses memoisation to cache query results. This means that if you call a function multiple times with the same input, the values returned the first time are stored and reused from the second time.

Cached objects are stored in the memory and do not persist across R sessions.

Disclaimer

This package is in no way affiliated with the German Federal Statistical Office (Destatis) or the ‘Verbund Statistische Ämter des Bundes und der Länder’. It is a simple wrapper providing R functions to access Destatis’ API. The package authors are in no way responsible for the data that can be retrieved using its functions. The license of this package solely applies to its source code.

Copy Link

Version

Install

install.packages('restatis')

Monthly Downloads

582

Version

0.2.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Buhl Yannik

Last Published

July 25th, 2024

Functions in restatis (0.2.0)

gen_cube

gen_cube
gen_metadata_table

gen_metadata_table
gen_metadata_val

Search for Meta-Information for a Value
gen_download_job

gen_download_job
gen_metadata_stats

Search for Meta-Information for a Statistic
is_cube_metadata_header

is_cube_metadata_header
gen_modified_data

gen_modified_data
gen_metadata_tab

Search for Meta-Information for a Table
insert_and_save_credentials

insert_and_save_credentials
gen_metadata_variable

gen_metadata_variable
gen_objects2stat

gen_objects2stat
read_cube_metadata_header

read_cube_metadata_header
gen_objects2var

gen_objects2var
ggsub

ggsub
gen_var2stat

gen_var2stat
rename_cube_data_columns

rename_cube_data_columns
param_check_year

param_check_year
gen_val2var2stat

gen_val2var2stat
gen_val2var

gen_val2var
param_check_regionalkey

param_check_regionalkey
gen_search_vars

gen_search_vars
resp_check_data

resp_check_data
gen_signs

gen_signs
restatis-package

restatis: R Wrapper to Access a Wide Range of Germany's Federal Statistical System Databases Based on the GENESIS Web Service RESTful API of the German Federal Statistical Office (Statistisches Bundesamt/Destatis)
test_database_function

test_database_function
param_collapse_vec

param_collapse_vec
read_cube

read_cube
test_if_json

test_if_json
titel_search

titel_search
test_if_error_find

test_if_error_find
test_if_error_light

test_if_error_light
test_if_error_variables

test_if_error_variables
gen_update_evas

gen_update_evas
gen_metadata_var

Search for Meta-Information for a Variable
read_cube_data_lines

read_cube_data_lines
test_if_error

test_if_error
gen_table

gen_table
read_cube_block

read_cube_block
test_if_process_further

test_if_process_further
test_if_okay

test_if_okay
gen_metadata_value

gen_metadata_value
split_cube

split_cube
spezifisch_create

spezifisch_create
return_table_object

return_table_object
logincheck_http_error

logincheck_http_error
logincheck_stop_or_warn

logincheck_stop_or_warn
rev_database_function

rev_database_function
gen_alternative_terms

gen_alternative_terms
forming_evas

forming_evas
gen_auth_get

gen_auth_get
evas_list

List of EVAS Codes
gen_auth_ask

gen_auth_ask
find_token

find_token
check_results

check_results
check_function_input

check_function_input
gen_auth_path

gen_auth_path
binding_lapply

binding_lapply
gen_metadata_cube

Search for Meta-Information for a Cube
gen_find

General Search for Objects Through GENESIS
gen_logincheck

gen_logincheck
gen_list_jobs

gen_list_jobs
gen_auth_save

gen_auth_save
gen_metadata

Search for Meta-Information for All Types of Objects
gen_catalogue

gen_catalogue
gen_metadata_statistic

gen_metadata_statistic