Package 'restatis'

Title: 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)
Description: A RESTful API wrapper for accessing the GENESIS database of the German Federal Statistical Office (Destatis) as well as its Census Database and the database of Germany's regional statistics. Supports data search functions, credential management, result caching, and handling remote background jobs for large datasets.
Authors: Yannik Buhl [aut, cre], Zoran Kovacevic [aut] , Dorian Le Jeune [aut], Long Nguyen [aut] , Johannes Ritter [aut]
Maintainer: Yannik Buhl <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2024-10-27 06:20:52 UTC
Source: https://github.com/correlaid/restatis

Help Index


binding_lapply

Description

binding_lapply

Usage

binding_lapply(x, characteristics)

Arguments

x

Element to bind

characteristics

Characteristics to filter for


check_function_input

Description

check_function_input

Usage

check_function_input(
  code = NULL,
  term = NULL,
  sortcriterion = NULL,
  category = NULL,
  detailed = NULL,
  type = NULL,
  date = NULL,
  similarity = NULL,
  error.ignore = NULL,
  ordering = NULL,
  database = NULL,
  area = NULL,
  caller = NULL,
  verbose = NULL,
  raw = NULL
)

Arguments

code

Parameter to be checked

term

Parameter to be checked

sortcriterion

Parameter to be checked

category

Parameter to be checked

detailed

Parameter to be checked

type

Parameter to be checked

date

Parameter to be checked

similarity

Parameter to be checked

error.ignore

Parameter to be checked

ordering

Parameter to be checked

database

Parameter to be checked

area

Parameter to be checked

caller

Parameter to be checked

verbose

Parameter to be checked

raw

Parameter to be checked


check_results

Description

check_results

Usage

check_results(input)

Arguments

input

Input to test result structure


List of EVAS Codes

Description

List of EVAS Codes

Usage

evas_list

Format

evas_list

A data frame with 1132 rows and 3 columns:

EVAS

EVAS code

Beschreibung

Details on the EVAS code

Titel

Alternative desription of EVAS code contents

Source

https://www.destatis.de/DE/Methoden/Revisionen/Glossar/EVAS.html


find_token

Description

find_token

Usage

find_token(input, error.input, text, sub_category)

Arguments

input

Input to test result structure

error.input

error.ignore TRUE or FALSE

text

verbose TRUE or FALSE

sub_category

sub_category character string


forming_evas

Description

forming_evas

Usage

forming_evas(list_of)

Arguments

list_of

List of EVAS to iterate over


gen_alternative_terms

Description

Function to find search terms that are similar or related to one another in spelling and also represented in the GENESIS, Zensus 2022 or regionalstatistik.de databases. Important note: The API call is searching for terms with the same characters. To be useful in searching for related terms it is highly recommended to work with "*" placeholders (see examples). The placeholder can be placed before and/or after the search term.

Usage

gen_alternative_terms(
  term = NULL,
  similarity = TRUE,
  database = c("all", "genesis", "zensus", "regio"),
  verbose = TRUE,
  ...
)

Arguments

term

Character string. Maximum length of 15 characters. Term or word for which you are searching for alternative or related terms. Use of '*' as a placeholder is possible to generate broader search areas.

similarity

Boolean. Indicator if the output of the function should be sorted based on a Levenshtein edit distance based on the adist() function. Default is 'TRUE'.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recollected elements from the respective database. Attributes are added to the data.frame, describing the search configuration for the returned output.

Examples

## Not run: 
# Find terms at GENESIS that are the same (in spelling) to search term "bus"
# and sort them by Levenshtein edit distance
object <- gen_alternative_terms(term = "bus", similarity = TRUE, database = "genesis")

# Find terms at GENESIS that are related (in spelling) to search term "bus"
object <- gen_alternative_terms(term = "bus*", similarity = TRUE, database = "genesis")

# Find terms at Zensus 2022 that are related (in spelling) to search term "wohn"
object <- gen_alternative_terms(term = "wohn*", similarity = TRUE, database = "zensus")

## End(Not run)

gen_auth_ask

Description

gen_auth_ask

Usage

gen_auth_ask(credential_type)

Arguments

credential_type

Character string. Type of credential to ask for

Value

The user response


gen_auth_get

Description

Function to retrieve the credentials stored via gen_auth_save()

Usage

gen_auth_get(database = c("all", "genesis", "zensus", "regio"))

Arguments

database

Character string. The database to get the credentials for ('all', 'genesis', 'zensus' and 'regio').

Value

Credentials for the database(s) chosen by the user

Examples

## Not run: 
gen_auth_get("all")

## End(Not run)

gen_auth_path

Description

gen_auth_path

Usage

gen_auth_path(...)

Arguments

...

Optional arguments for file.path()

Value

A file path for the storage of config files


gen_auth_save

Description

Save credentials of the different databases for further convenient use

Usage

gen_auth_save(database = c("all", "genesis", "zensus", "regio"))

Arguments

database

Character string. The database to store credentials for ('all', 'genesis', 'zensus' or 'regio').

Details

Username and password are encrypted and saved as RDS in the package config directory. A random string is generated and stored in the session environment variable GENESIS_KEY. This string is used as the key to encrypt and decrypt the entered credentials. To avoid havding to save authentication in future sessions, GENESIS_KEY can be added to .Renviron. The usethis package includes a helper function for editing .Renviron files from an R session with usethis::edit_r_environ().

Value

Path to the RDS file in which credentials are saved, invisibly.

Examples

## Not run: 
gen_auth_save("zensus")

## End(Not run)

gen_catalogue

Description

Function to search for tables, statistics, and cubes from GENESIS, Zensus 2022 or regionalstatistik.de. Additionally, it structures the output based on the internal tree structure based on the EVAS-numbers. Time-series are represented as cubes with a specified time span. Important note: To be useful in searching for objects it is highly recommended to work with "*" placeholders (see examples). The placeholder can be placed before and/or after the search term.

Usage

gen_catalogue(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  category = c("tables", "statistics", "cubes"),
  area = c("all", "public", "user"),
  detailed = FALSE,
  sortcriterion = c("code", "content"),
  error.ignore = FALSE,
  verbose = TRUE,
  ...
)

Arguments

code

String with a maximum length of 15 characters for a database object (GENESIS and regionalstatistik.de) and 15 characters for a Zensus 2022 object. Only one code per iteration. "*" notations are possible.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

category

Character string. Specify specific GENESIS/regionalstatistik.de object types ('tables', 'statistics' and 'cubes') and specific Zensus 2022 object types ('tables' and 'statistics'). All types that are specific for one database can be used together. Default option is to use all types that are possible for the specific database.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

detailed

Boolean. Indicator if the function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. Default option is 'FALSE'.

sortcriterion

Character string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the API call itself. The default is 'code'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Based on the 'detailed' parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Scroll through objects under the topic "12*"
# which is "Bevoelkerung" in GENESIS from all categories and
# with a detailed output
object <- gen_catalogue(code = "12*", detailed = TRUE)

# Search tables under the topic "12*" which is "Bevölkerung"
# without a detailed output
object <- gen_catalogue(code = "12*", category = "tables")

## End(Not run)

gen_cube

Description

Download a cube with data from GENESIS or regionalstatistik.de database

Usage

gen_cube(name, ...)

Arguments

name

Character string for a cube object (only GENESIS and regionalstatistik.de)

...

Further (optional) parameters passed on to the API call:

area

Character string. The area in which the table is stored. Possible values:

  • "public": cube in the public catalogue

  • "user": cube in the user's account

  • "all": both of the above

values

Boolean. Should values be included?

metadata

Boolean. Should metadata be included?

additionals

Boolean. Should additional metadata be included?

contents

Character string. Names of required statistical specifications

startyear,endyear

Four-digit integers. Only retrieve data between these years.

timeslices

Integer. Number of timeslices (cumulative to startyear or endyear)

regionalvariable

Character string. Code of the regional variable whose value is specified in regionalkey to filter the results.

regionalkey

Character string. One or more regional keys. Multiple values can be supplied as a character vector or as a single string, with the regional keys separated by commas. Use of wildcard (*) allowed.

classifyingvariable1,classifyingvariable2 ,classifyingvariable3

Character string. Code of the subject classification (SK-Merkmal) to which the selection by means of the corresponding classifyingkey parameter is to be applied.

classifyingkey1,classifyingkey2,classifyingkey3

Character string. One or more values of a subject classification (e.g. "WZ93012"). Applied to the corresponding classifyingvariable parameter. Multiple keys can be supplied as a character vector or as a single string, with the keys separated by commas. Use of wildcard (*) allowed.

stand

Character string, format: "DD.MM.YYYY". Only retrieve data updated after this date.

language

Character string. Search terms, returned messages and data descriptions in German ("de") or English ("en")?

Value

A tibble. Non-data contents of the data cube object are saved in the metadata attribute of the data frame.

Examples

## Not run: 
gen_cube("47414BJ002")

## End(Not run)

gen_download_job

Description

gen_download_job

Usage

gen_download_job(
  name,
  database = c("genesis", "regio"),
  area = c("all", "public", "user"),
  compress = FALSE,
  language = Sys.getenv("GENESIS_LANG"),
  all_character = TRUE
)

Arguments

name

Character string. The job code retrieved by using gen_list_jobs().

database

Character string. Indicator if the GENESIS ('genesis') or regionalstatistik.de ('regio') database is called. Only one database can be addressed per function call. Default option is 'genesis'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'.

compress

Boolean. Should empty rows and columns be discarded? Default is FALSE.

language

Character string. Defines if the decimal mark and grouping mark of integers should be represented based on the European (e.g.: '100,5', '200.000,5') or American ('100.5', '200,000.5') system. Defaults to 'Sys.getenv("GENESIS_LANG")'.

all_character

Boolean. Should all variables be imported as 'character' variables? Avoids fuzzy data type conversions if there are leading zeros or other special characters. Defaults to TRUE.

Value

Returns a data.frame with the table content

Examples

## Not run: 
gen_download_job("21311-00-01-1_123456789", "regio")

## End(Not run)

General Search for Objects Through GENESIS

Description

Function to search through the databases GENESIS, Zensus 2022 and regionalstatistik.de. It is similar in usage as the search function on the GENESIS main page (https://www-genesis.destatis.de/genesis/online). In the search query, "UND" (German word for 'and', also written "und" or "&") as well as "ODER" (German word for 'or', also written "oder" or "|") can be included and logically combined. Furthermore, wildcards are possible by including "*". If more then one word is included in the term string, 'and' is used automatically to combine the different words. Important note: Time-series are treated as cubes in GENESIS and regionalstatistik.de, they are not longer distinguished. If you want to find a specific object with a clear code with this find function, you need to specify the object type or search for all object types.

Usage

gen_find(
  term = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  category = c("all", "tables", "statistics", "variables", "cubes"),
  detailed = FALSE,
  ordering = TRUE,
  error.ignore = TRUE,
  verbose = TRUE,
  ...
)

Arguments

term

A character string with no maximum character length, but a word limit of five words.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

category

Character string. Specify specific GENESIS/regionalstatistik.de object types ('tables', 'statistics' and 'cubes') and specific Zensus 2022 object types ('tables' and 'statistics'). All types that are specific for one database can be used together. Default option is to use all types that are possible for the specific database.

detailed

Boolean. Indicator if the function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. Default option is 'FALSE'.

ordering

A logical. Indicator if the function should return the output of the iteration ordered first based on the fact if the searched term is appearing in the title of the object and secondly on an estimator of the number of variables in this object. Default option is 'TRUE'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'TRUE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Based on the 'detailed' parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find objects related to "bus" in GENESIS
object <- gen_find(term = "bus")

# Find tables related to "bus" in GENESIS and return a unordered detailed output
object <- gen_find(term = "bus", detailed = TRUE, ordering = FALSE)

# Find tables related to "Autos" or "Corona" in GENESIS and return a unordered detailed output
object <- gen_find(term = "autos ODER corona", detailed = TRUE, ordering = FALSE)

#' # Find tables related to "Autos" and "Corona" in GENESIS and return a unordered detailed output
object <- gen_find(term = "autos UND corona", detailed = TRUE, ordering = FALSE)

## End(Not run)

gen_list_jobs

Description

Function to list all current jobs connected to the given user in the GENESIS or regionalstatistik.de database. Important note: For this function it is also possible to use searchcriterion parameter and selection parameter, making it possible to filter the job list based on 'type','time','status' or 'code'. For more details see vignette("additional_parameter").

Usage

gen_list_jobs(
  database = c("genesis", "regio"),
  sortcriterion = c("type", "time", "status", "code"),
  flat = FALSE,
  ...
)

Arguments

database

Character string. Indicator if 'genesis' or 'regionalstatistik.de' database is called. Default option is 'genesis'.

sortcriterion

Character string. Indicator if the output should be sorted by 'type','time','status' or 'code'. This is a parameter of the API call itself. The default is 'type'.

flat

Boolean. Should the function return a list with jobs and metadata ('FALSE') or just a flat data.frame ('TRUE')? Defaults to FALSE.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list or data.frame (see parameter 'flat') of all current jobs of the user.

Examples

## Not run: 
gen_list_jobs("regio", flat = TRUE)

## End(Not run)

gen_logincheck

Description

Function to check if a login is possible for a certain database.

Usage

gen_logincheck(database, verbose = FALSE)

Arguments

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Only one database can be addressed per function call. Default option is 'genesis'.

verbose

Boolean. In case of success, should a message be printed? Defaults to FALSE.

Value

Leads to an informative error message if the login check failed and returns FALSE invisibly. Invisibly returns TRUE otherwise.

Examples

## Not run: 
gen_logincheck("zensus")

## End(Not run)

gen_metadata

Description

Search For Meta-Information For All Types Of Objects

Usage

gen_metadata(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  category = c("cube", "statistic", "table", "variable", "value"),
  area = c("all", "public", "user"),
  error.ignore = FALSE,
  verbose = TRUE,
  raw = FALSE,
  ...
)

Arguments

code

String with a maximum length of 15 characters for a database object (GENESIS, regionalstatistik.de, Zensus 2022). Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

category

Character string. Specifying the specific object type of the object that you want meta data for. No default option - you need to specify the object type. Hint: The functions in 'restatis' often return information on object 'Type'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

raw

Boolean. Should a non-parsed API response be returned? Default option is 'FALSE'.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find meta-information of the table with the code "11111"
object <- gen_metadata(code = "11111", category = "table", database = "genesis")

## End(Not run)

gen_metadata_cube

Description

Function to search for meta information for a specific cube. Usable only for GENESIS and regionalstatistik.de.

Usage

gen_metadata_cube(
  code = NULL,
  database = c("all", "genesis", "regio"),
  area = c("all", "public", "user"),
  error.ignore = FALSE,
  verbose = TRUE,
  raw = FALSE,
  ...
)

Arguments

code

A character string with a maximum length of 15 characters. Code from a GENESIS or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

raw

Boolean. Should a non-parsed API response be returned? Default option is 'FALSE'.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find meta-information of the cube with the code "11111KE001"
object <- gen_metadata_cube(code = "11111KE001")

## End(Not run)

gen_metadata_statistic

Description

Function to search for meta information for a specific statistic.

Usage

gen_metadata_statistic(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  area = c("all", "public", "user"),
  error.ignore = FALSE,
  verbose = TRUE,
  raw = FALSE,
  ...
)

Arguments

code

A character string with a maximum length of 15 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

raw

Boolean. Should a non-parsed API response be returned? Default option is 'FALSE'.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find meta-information of the statistic with the code "12411"
object <- gen_metadata_stats(code = "12411")

## End(Not run)

gen_metadata_table

Description

Function to search for meta information for a specific table.

Usage

gen_metadata_table(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  area = c("all", "public", "user"),
  error.ignore = FALSE,
  verbose = TRUE,
  raw = FALSE,
  ...
)

Arguments

code

A character string with a maximum length of 15 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

raw

Boolean. Should a non-parsed API response be returned? Default option is 'FALSE'.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find meta-information of the table with the code "11111"
object <- gen_metadata_tab(code = "11111")

## End(Not run)

gen_metadata_value

Description

Function to search for meta information for a specific value.

Usage

gen_metadata_value(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  area = c("all", "public", "user"),
  error.ignore = FALSE,
  verbose = TRUE,
  raw = FALSE,
  ...
)

Arguments

code

A character string with a maximum length of 15 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

raw

Boolean. Should a non-parsed API response be returned? Default option is 'FALSE'.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find meta-information of the value with the code "LEDIG"
object <- gen_metadata_val(code = "LEDIG")

## End(Not run)

gen_metadata_variable

Description

Function to search for meta information for a specific variable.

Usage

gen_metadata_variable(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  area = c("all", "public", "user"),
  error.ignore = FALSE,
  verbose = TRUE,
  raw = FALSE,
  ...
)

Arguments

code

A character string with a maximum length of 15 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

raw

Boolean. Should a non-parsed API response be returned? Default option is 'FALSE'.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find meta-information of the variable with the code "FAMSTD"
object <- gen_metadata_var(code = "FAMSTD")

## End(Not run)

gen_modified_data

Description

Function to check for updates, changes, or new objects based on a specific date.

Usage

gen_modified_data(
  code = "",
  database = c("all", "genesis", "zensus", "regio"),
  type = c("all", "tables", "statistics", "statisticsUpdates"),
  date = c("now", "week_before", "month_before", "year_before"),
  verbose = TRUE,
  ...
)

Arguments

code

A character string with a maximum length of 15 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

type

Character string. Specific GENESIS and regionalstatistik.de object types: 'tables', 'statistics', and 'statisticsUpdates'. Specific Zensus 2022 object types: 'tables' and 'statistics'. All types that are specific for one database can be used together through 'all', which is the default.

date

Character string. Specific date that is used as the last update or upload time to include an object in return. Default option is 'now', which uses the current date of your system. Alternative options are 'week_before', using the current date of your system minus 7 days, 'month_before', using the current date of your system minus 4 weeks, and 'year_before', using the current date of your system minus 52 weeks. Additionally, it is possible to fill in a specific date of format 'DD.MM.YYYY'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find objects which were modified last_week
object <- gen_modified_data(date = "week_before")

# Find tables that were new from 31.03.2020
object <- gen_modified_data(type = "tables", date = "31.03.2020")

# Find objects related to the topic "Bevölkerung" (Code: '12*') which were new today
object <- gen_modified_data(code = "12*")

## End(Not run)

gen_objects2stat

Description

Function to find objects related to a statistic

Usage

gen_objects2stat(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  category = c("tables", "variables", "cubes"),
  area = c("all", "public", "user"),
  detailed = FALSE,
  sortcriterion = c("code", "content"),
  error.ignore = FALSE,
  verbose = TRUE,
  ...
)

Arguments

code

Character string with a maximum length of 6 characters (15 characters if 'cubes' are not used as a category). Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

category

Character string. Specify specific GENESIS/regionalstatistik.de object types ('tables', 'statistics' and 'cubes') and specific Zensus 2022 object types ('tables' and 'statistics'). All types that are specific for one database can be used together. Default option is to use all types that are possible for the specific database.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

detailed

Boolean. Indicator if the function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. Default option is 'FALSE'.

sortcriterion

Character string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the API call itself. The default is 'code'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Based on the 'detailed' parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find cubes from the statistic with the code "21111" with a detailed return
 object <- gen_objects2stat(code = "21111", category = "cubes", detailed = T)

# Find all object types from the statistic with the code "12411"
object <- gen_objects2stat(code = "12411")
# Default of detailed-parameter is FALSE, and default of the
# category-parameter is to include all object types.

## End(Not run)

gen_objects2var

Description

Function to find objects related to a variable

Usage

gen_objects2var(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  category = c("tables", "statistics", "cubes"),
  area = c("all", "public", "user"),
  detailed = FALSE,
  sortcriterion = c("code", "content"),
  error.ignore = FALSE,
  verbose = TRUE,
  ...
)

Arguments

code

Character string with a maximum length of 15 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

category

Character string. Specify specific GENESIS/regionalstatistik.de object types ('tables', 'statistics' and 'cubes') and specific Zensus 2022 object types ('tables' and 'statistics'). All types that are specific for one database can be used together. Default option is to use all types that are possible for the specific database.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

detailed

Boolean. Indicator if the function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. Default option is 'FALSE'.

sortcriterion

Character string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the API call itself. The default is 'code'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Based on the 'detailed' parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find Tables for Variable "Kreise" and return detailed output
object <- gen_objects2var(code = "Kreise", category = "tables", detailed = T)

# Find everything for Variable "GES"
object <- gen_objects2var(code = "GES")
# Default of detailed-parameter is FALSE, and default of the
# category-parameter is to include all object types.

## End(Not run)

gen_search_vars

Description

Function to search for specific variables

Usage

gen_search_vars(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  area = c("all", "public", "user"),
  sortcriterion = c("code", "content"),
  error.ignore = FALSE,
  verbose = TRUE,
  ...
)

Arguments

code

Character string with a maximum length of 6 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

sortcriterion

Character string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the API call itself. The default is 'code'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find a specific variable "GES" in Genesis
object <- gen_search_vars("GES")

## End(Not run)

gen_signs

Description

Function to list all currently used special signs (e.g., 0, *, X, (), p, ...) and their meaning in GENESIS, Zensus 2022 and/or regionalstatistik.de.

Usage

gen_signs(database = c("all", "genesis", "zensus", "regio"), ...)

Arguments

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list of all current used special signs.


gen_table

Description

Download a table with data from GENESIS, Zensus 2022 or regionalstatistik.de databases

Usage

gen_table(name, ...)

Arguments

name

Character string. Name/code of the table. Use of wildcards (*) is possible.

...

Optional parameters passed on to the Genesis API call:

area

Character string. The area in which the table is stored. Possible values:

  • "public": table in the public catalogue

  • "user": table in the user's account

  • "all": both of the above

compress

Boolean. Should empty rows and columns be discarded?

transpose

Boolean. Reshape the table between "wide" and "long" format.

startyear,endyear

Four-digit integers. Only retrieve data between these years.

regionalvariable

Character string. Code of the regional variable whose value is specified in regionalkey to filter the results.

regionalkey

Character string. One or more regional keys. Multiple values can be supplied as a character vector or as a single string, with the regional keys separated by commas. Use of wildcard (*) allowed.

classifyingvariable1,classifyingvariable2 ,classifyingvariable3

Character string. Code of the subject classification (SK-Merkmal) to which the selection by means of the corresponding classifyingkey parameter is to be applied.

classifyingkey1,classifyingkey2,classifyingkey3

Character string. One or more values of a subject classification (e.g. "WZ93012"). Applied to the corresponding classifyingvariable parameter. Multiple keys can be supplied as a character vector or as a single string, with the keys separated by commas. Use of wildcard (*) allowed.

stand

Character string, format: "DD.MM.YYYY". Only retrieve data updated after this date.

language

Search terms, returned messages and data descriptions in German ("de") or English ("en")?

job

Boolean. Indicate as to whether a job should be created (not available with the 'Zensus' database).)

all_character

Boolean. Should all variables be imported as 'character' variables? Avoids fuzzy data type conversions if there are leading zeros or other special characters. Defaults to TRUE.

Value

A tibble.

Examples

## Not run: 
gen_table("21311-0001")

## End(Not run)

gen_update_evas

Description

Function to web scrape the EVAS numbers from the EVAS website and save them as a .rda file. Takes no parameters.

Usage

gen_update_evas()

Value

An updated .rda file containing the latest EVAS numbers


gen_val2var

Description

Function to extract the possible values from a variable. Values for continuous variables are not extractable, which is why the function returns a warning message in this case.

Usage

gen_val2var(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  area = c("all", "public", "user"),
  sortcriterion = c("code", "content"),
  error.ignore = TRUE,
  verbose = TRUE,
  ...
)

Arguments

code

Character string with a maximum length of 15 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

sortcriterion

Character string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the API call itself. The default is 'code'.

error.ignore

Boolean. Indicator for values if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'TRUE', this prevents the function to stop even if a variable has no further explanation (often the case for numerical variables).

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find the values of the variable "DLAND"
object <- gen_val2var(code = "DLAND")

## End(Not run)

gen_val2var2stat

Description

Get values from variables from a statistic. Values for continuous variables cannot be extracted, so the function returns a warning message.

Usage

gen_val2var2stat(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  area = c("all", "public", "user"),
  detailed = FALSE,
  sortcriterion = c("code", "content"),
  error.ignore.var = FALSE,
  error.ignore.val = TRUE,
  verbose = TRUE,
  ...
)

Arguments

code

Character string with a maximum length of 15 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

detailed

Boolean. Indicator if the function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. Default option is 'FALSE'.

sortcriterion

Character string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the API call itself. The default is 'code'.

error.ignore.var

Boolean. Indicator for variables if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

error.ignore.val

Boolean. Indicator for values if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'TRUE', this prevents the function to stop even if a variable has no further explanation (often the case for numerical variables).

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Based on the 'detailed' parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find the values of variables in a specific statistic with
# the code "21111" and a detailed description of the variables
object <- gen_val2var2stat(code = "21111", detailed = TRUE)

## End(Not run)

gen_var2stat

Description

Function to generate variables from statistics

Usage

gen_var2stat(
  code = NULL,
  database = c("all", "genesis", "zensus", "regio"),
  area = c("all", "public", "user"),
  detailed = FALSE,
  sortcriterion = c("code", "content"),
  error.ignore = FALSE,
  verbose = TRUE,
  ...
)

Arguments

code

Character string with a maximum length of 15 characters. Code from a GENESIS, Zensus 2022 or regionalstatistik.de object. Only one code per iteration.

database

Character string. Indicator if the GENESIS ('genesis'), Zensus 2022 ('zensus') or regionalstatistik.de ('regio') database is called. Default option is 'all'.

area

Character string. Indicator from which area of the database the results are called. In general, 'all' is the appropriate solution. Default option is 'all'. Not used for 'statistics'.

detailed

Boolean. Indicator if the function should return the detailed output of the iteration including all object-related information or only a shortened output including only code and object title. Default option is 'FALSE'.

sortcriterion

Character string. Indicator if the output should be sorted by 'code' or 'content'. This is a parameter of the API call itself. The default is 'code'.

error.ignore

Boolean. Indicator if the function should stop if an error occurs or no object for the request is found or if it should produce a token as response. Default option is 'FALSE'.

verbose

Boolean. Indicator if the output of the function should include detailed messages and warnings. Default option is 'TRUE'. Set the parameter to 'FALSE' to suppress additional messages and warnings.

...

Additional parameters for the API call. These parameters are only affecting the call itself, no further processing. For more details see vignette("additional_parameter").

Value

A list with all recalled elements from the API. Based on the 'detailed' parameter it contains more or less information, but always includes the code of the object, the title, and the type of the object. This is done to facilitate further processing with the data. Attributes are added to the data.frame describing the search configuration for the returned output.

Examples

## Not run: 
# Find the variables of the statistic with the code "12411"
# with a detailed output
object <- gen_var2stat(code = "12411", detailed = T)

## End(Not run)

ggsub

Description

ggsub

Usage

ggsub(x)

Arguments

x

Element to subset with $Content


insert_and_save_credentials

Description

insert_and_save_credentials

Usage

insert_and_save_credentials(database)

Arguments

database

The database to specify credentials for


is_cube_metadata_header

Description

is_cube_metadata_header

Usage

is_cube_metadata_header(lines)

Arguments

lines

Lines to check for header


logincheck_http_error

Description

logincheck_http_error

Usage

logincheck_http_error(database, verbose)

Arguments

database

The user input to 'gen_logincheck'

verbose

Boolean. Should the function message in case of success?

Value

Informative error/warning messages + invisibly TRUE/FALSE


logincheck_stop_or_warn

Description

logincheck_stop_or_warn

Usage

logincheck_stop_or_warn(response, error, verbose, database)

Arguments

response

A HTTP response object

error

Boolean. Should the function warn or throw an error?

verbose

Boolean. Should the function message in case of success?

database

The database that the check should be run for

Value

In case of failure warns or errors. Invisibly returns TRUE (success) or FALSE (failure)


param_check_regionalkey

Description

param_check_regionalkey

Usage

param_check_regionalkey(regionalkey)

Arguments

regionalkey

Regional key


param_check_year

Description

param_check_year

Usage

param_check_year(year)

Arguments

year

Year as parameter value


param_collapse_vec

Description

param_collapse_vec

Usage

param_collapse_vec(vec)

Arguments

vec

Vector to be collapsed


read_cube

Description

read_cube

Usage

read_cube(resp)

Arguments

resp

API response object resulting from a call to 'data/cubefile'


read_cube_block

Description

read_cube_block

Usage

read_cube_block(lines)

Arguments

lines

Lines to read as header


read_cube_data_lines

Description

read_cube_data_lines

Usage

read_cube_data_lines(lines, col_names)

Arguments

lines

Lines to read data from

col_names

Specify column names


read_cube_metadata_header

Description

read_cube_metadata_header

Usage

read_cube_metadata_header(line, rename_dups = TRUE)

Arguments

line

Line to read

rename_dups

Rename duplicates?


rename_cube_data_columns

Description

rename_cube_data_columns

Usage

rename_cube_data_columns(cube)

Arguments

cube

A cube object to rename the columns in


resp_check_data

Description

resp_check_data

Usage

resp_check_data(resp)

Arguments

resp

Response object


return_table_object

Description

return_table_object

Usage

return_table_object(response, response_type, language, all_character)

Arguments

response

Response object

response_type

Response type

language

Language locale

all_character

Read all variables as character?


rev_database_function

Description

rev_database_function

Usage

rev_database_function(input)

Arguments

input

Input to test for database name


spezifisch_create

Description

spezifisch_create

Usage

spezifisch_create(x)

Arguments

x

Element to extract $Spezifisch from


split_cube

Description

split_cube

Usage

split_cube(lines)

Arguments

lines

Lines to split a cube


test_database_function

Description

test_database_function

Usage

test_database_function(input, error.input, text)

Arguments

input

Input to test for database name

error.input

Indicator error.ignore

text

Indicator verbose


test_if_error

Description

test_if_error

Usage

test_if_error(input, para, verbose = NULL)

Arguments

input

Response object

para

Parameter TRUE/FALSE

verbose

Verbose TRUE/FALSE


test_if_error_find

Description

test_if_error_find

Usage

test_if_error_find(input, para, verbose = NULL)

Arguments

input

Response object

para

Parameter TRUE/FALSE

verbose

Verbose TRUE/FALSE


test_if_error_light

Description

test_if_error_light

Usage

test_if_error_light(input, verbose = NULL)

Arguments

input

Response object

verbose

Verbose TRUE/FALSE


test_if_error_variables

Description

test_if_error_variables

Usage

test_if_error_variables(input, para)

Arguments

input

Response object

para

Parameter TRUE/FALSE


test_if_json

Description

test_if_json

Usage

test_if_json(input)

Arguments

input

Response object


test_if_okay

Description

test_if_okay

Usage

test_if_okay(input)

Arguments

input

Response object


test_if_process_further

Description

test_if_process_further

Usage

test_if_process_further(input, para, verbose = NULL)

Arguments

input

Response object

para

Parameter TRUE/FALSE

verbose

Verbose TRUE/FALSE