Recode geographical codes to the current year. Codes is based on
norgeo::track_change() function. For a split geogaphical codes from
previous year, the first code of the current year code in chronological order
will be selected to recode.
Usage
do_geo_recode(
dt = NULL,
code = NULL,
type = c("grunnkrets", "fylke", "kommune", "bydel"),
year = NULL,
con = NULL,
geo = NULL,
base = NULL,
control = FALSE,
...
)Arguments
- dt
Input data preferrably in a
data.tableformat but is not mandatory- code
Code dataset of old and new codes in a
data.tableformat.- type
The geographical granularity for recoding. The dataset is the output after running
get_geo_recode()function.- year
Which year the geograhical codes to be recoded to. If it is empty then global option for
orgdata.yearwill be used.- con
Connection to database
- geo
Logical value. Keep old geographical code if TRUE. Default is FALSE.
- base
Logical value. If
TRUEthen use year in the original data as the base year to recode the geographical codes. Default isFALSEand use all available codes in geo codebook- control
Logical value.
TRUEif the file has been controlled for possible errors- ...
Any additional arguments
See also
Other geo recode functions:
do_recode_without_aggregate(),
get_geo_recode()
Examples
if (FALSE) { # \dontrun{
code <- get_geo_recode(con = geo$dbconn, type = "grunnkrets")
dt <- make_file("BEFOLKNING", aggregate = FALSE)
DT <- do_geo_recode(dt, code)
} # }
