if (FALSE) {
# Retrieve values for the table 14111KJ002 which contains the
# federal election results on the county level.
# Assumes that user/password are stored via save_credentials()
data <- retrieve_data(tablename="14111KJ002", genesis=c(db="regio") )
# ... only the values for the AfD.
data <- retrieve_data(tablename="14111KJ002", sachmerkmal="PART04",
sachschluessel="AFD", genesis=c(db="regio") )
# ... or only values from Saxony
data <- retrieve_data(tablename="14111KJ002", regionalmerkmal="KREISE",
regionalschluessel="14*", genesis=c(db="regio") )
# Limiting the number of data points is in particular important for
# large tables. For example, this data request fails:
data <- retrieve_data(tablename="33111GJ005", genesis=c(db='regio'))
# But after limiting the request to one year, the data is returned:
data <- retrieve_data(tablename="33111GJ005", genesis=c(db='regio'), startyear=2019, endyear=2019)
# An alternative strategy is to only request a subset of the variables.
# For example, this data request fails:
data <- retrieve_data("12711GJ002", genesis=c(db="regio"))
# But when requesting only one instead of all variables, the data is returned:
data <- retrieve_data("12711GJ002", inhalte="BEV081", genesis=c(db="regio"))
# Example using the sachschluessel: Number of refugees from Afghanistan (ST423)
# and Egypt (ST287) by district (Kreis) in 2022.
data <- retrieve_data("12531KJ003", startyear = 2022, endyear = 2022,
sachmerkmal="STAAG5", sachschluessel = "ST423, ST287", genesis=c(db='de'))
}
Run the code above in your browser using DataLab