Skip to contents

Geo codes other than those downloaded from SSB API can be merged to the main geo table ie. tblGeo in the geocodes database. The file must consist of id column to merge into ie. id.file and the geo codes to add to ie. geo.col.

Usage

geo_merge(
  id.table = NULL,
  id.file = NULL,
  geo.col = NULL,
  geo.level = NULL,
  geo.name = NULL,
  file = NULL,
  localtable = NULL,
  year = NULL,
  write = FALSE,
  table.name = "tblGeo",
  ...
)

Arguments

id.table

ID columname to merge to that is found in the database eg. kommune

id.file

ID columname from the file to merge from. This depends on the columnames in the files. If id.table is kommune, then id.file must be the columname representing geo codes that is equivalent to kommune codes. Both id.table and id.file will be used for merging and these codes must be unique.

geo.col

Columname where the new geo codes are eg. if the new geo codes is on levekaar, then geo.col is the columname where codes for levekaar can be found.

geo.level

Geographical level of the merged file will be representing eg. "levekaar". This will be the value in column level in the tblGeo in the database. the value in column name in the tblGeoin the database.

geo.name

Column containing names of the geographical units in the merged file. This will be the value in column namein the tblGeo in the database.

file

Complete path of filename to merge from

localtable

a data.table generated with geo_map_multi(). To create complete mapping table of geo codes including manually merged codes.

year

Year the code is valid for. If not sepecified orgdata.year is used.

write

Write table to the orgdata.geo database. It will overwrite the table if it already exists

table.name

Name of the table for geo recode in geocodes database. This can be found with getOptions("orgdata.geo"). The default is tblGeo.

...

Other possible arguments

Examples

if (FALSE) { # \dontrun{
dt <- geo_merge(id.table = "grunnkrets",
                id.file = "id",
                geo.col = "col2",
                geo.level = "levekaar",
                geo.name = "col3",
                file = "C:/path/to/file.csv",
                year = 2022)
} # }