Skip to contents

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.table format but is not mandatory

code

Code dataset of old and new codes in a data.table format.

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.year will be used.

con

Connection to database

geo

Logical value. Keep old geographical code if TRUE. Default is FALSE.

base

Logical value. If TRUE then use year in the original data as the base year to recode the geographical codes. Default is FALSE and use all available codes in geo codebook

control

Logical value. TRUE if 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)
} # }