sp_add_codelist | R Documentation |
Joins a provided codelist, or downloads and processes one if necessary, and adds it to the data.
sp_add_codelist(
data,
codelist = NULL,
period_column = .data$vykaz_date,
by = NULL,
redownload = FALSE,
dest_dir = NULL
)
data |
a data frame returned by |
codelist |
The codelist to add. Either a character vector of length one (see |
period_column |
Unquoted column name of column identifying the data period in |
by |
character. Columns by which to join the codelist. Same form as for |
redownload |
Redownload even if file has already been downloaded? Defaults to FALSE. |
dest_dir |
character. Directory in which downloaded files will be stored.
If left unset, will use the |
The data
argument should be a data frame produced by sp_get_table()
If this is true, the period_column
argument is not needed.
The codelist
argument, if a data frame, should be a data frame produced by
sp_get_codelist()
. Specifically, it assumes it contains the following columns:
start_date, a date
end_date, a date
column with the code, character usually named the same as the codelist
#' You can usually tell which codelist you need from the name of the column whose code you are looking to expand, e.g. the codes in column paragraf can be expanded by codelist paragraf.
The function filters the codelist to obtain a set of entries relevant to the time period of data
.
If data
contains tables for multiple periods, this is handled appropriately.
Codelist-originating columns in the resulting data frame are renamed so they do not interfere with
joining additional codelists, perhaps in a single pipe call.
Note that some codelists are "secondary" and can only be joined onto other codelists.
If a codelist does not join using sp_add_codelis()
, store the output of sp_get_codelist()
and join
it manually using dplyr
.
A tibble of same length as data
, with added columns from codelist
. See Details.
Other Core workflow:
add_codelist()
,
get_codelist()
,
sp_get_codelist()
,
sp_get_dataset()
,
sp_get_table()
## Not run:
sp_get_table("budget-central", 2017) %>%
sp_add_codelist("polozka") %>%
sp_add_codelist("paragraf")
pol <- sp_get_codelist("paragraf")
par <- sp_get_codelist("polozka")
sp_get_table("budget-central", 2017) %>%
sp_add_codelist(pol) %>%
sp_add_codelist(par)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.