czso_get_table {czso} | R Documentation |
Retrieve and read dataset from CZSO
Description
Downloads and reads dataset identified by dataset_id
.
Unzips if necessary, but only loads CSV files, otherwise returns the path to the downloaded file.
Converts types of columns where known, e.g. value columns to numeric.
Usage
czso_get_table(
dataset_id,
dest_dir = NULL,
force_redownload = FALSE,
resource_num = 1
)
Arguments
dataset_id |
a character. Found in the czso_id column of data frame returned by |
dest_dir |
character. Directory in which downloaded files will be stored.
If left unset, will use the |
force_redownload |
integer. Whether to redownload data source file even if already cached. Defaults to FALSE. |
resource_num |
integer. Order of resource in resource list for the given dataset. Defaults to 1, the normal value for CZSO datasets. |
Details
Structure of the output tibble
CZSO provides its open data as tidy data, so each row only contains one value
in the hodnota
column and the remaining columns give details on how
that value is defined. See "Included columns" below on how these work.
Data types
The schema of the dataset is not yet used, so some columns may be mistyped and are by default returned as character vectors.
Included columns
The range of columns present in the output varies from one dataset to another, so the package does not attempt to provide English-language names for the known subset, as that would result in a jumble of Czenglish.
Instead, here is a guide to some of the common column names you will encounter:
-
idhod
: a unique ID of the value in the CZSO database. This does not allow you to link to any other (meta)data as far as I know, but it does provide unique identification should you need it. -
hodnota
: the value. -
stapro_kod
: code of the statistic/indicator/variable as listed. in the SMS UKAZ register (https://www.czso.cz/csu/czso/statistical-variables-indicators); this one has Czech-English documentation - access this by clicking the UK flag top right. You can also get a data table with the definitions, if you search for"statistické proměnné"
in thetitle
field of the catalogue. Last I checked, the ID of this table was"990124-17"
. -
rok
denotes year as YYYY. -
ctvrtleti
denotes quarter if available.
Other metadata will come in the form {variable}_[txt|cis|kod]
. The _txt
column holds the Czech text name for the category. The _cis
column holds the
ID of the codelist (register) you need to decode the code in _kod
.
The English codelists are at http://apl.czso.cz/iSMS/en/cislist.jsp,
Czech ones at http://apl.czso.cz/iSMS/cs/cislist.jsp.
You can find the Czech-language codelists in the catalogue retrieved with
czso_get_catalogue()
, where their IDs begin with "cis"
followed by the number; the English ones can also be retrieved from
the link above using a permalink URL.
More conveniently, you can use the czso_get_codelist()
function to retrieve the codelist.
Units are denoted in a separate column.
A helper on common breakdowns with their associated columns:
-
uzemi
: territory -
vek
: age -
pohlavi
: gender
NA
s in "breakdown" columns (e.g. gender or age) denote the total.
Value
a tibble, or vector of file paths if file is not CSV or if there are multiple files in the dataset. See Details on the columns contained in the tibble
Note
Do not use this for harvesting datasets from CZSO en masse.
See Also
Other Core workflow:
czso_get_catalogue()
,
czso_get_codelist()
Examples
czso_get_table("110080")