Aggregate data according to the specification in tbl_Filgruppe
in AGGREGERE
column. The input in argument source
must be a lower
granularity level than the level
input.
Arguments
- dt
Input data preferrably in a
data.table
format but is not mandatory- source
What geographical granularity codes that is available in the source data. This will be used for merging with the geo codebook generated from
geo_map()
ie. fromtblGeo
in geo database- level
Geographical granularity for aggregating data. See
getOption("orgdata.geo.levels")
- year
Which year the geograhical codes to be recoded to. If it is empty then global option for
orgdata.year
will be used.- aggregate.col
Other columns to aggregate other than the standard ie.
UTDANN
,LANDSSB
,LANDBAK
andINNVKAT
- geoDT
Geo codes to aggregate dataset with
- check
If TRUE then output will keep variables for geographical levels without aggregating it. This is useful to check for geographical codes that are missing. Else use
options(orgdata.aggregate = FALSE)
- base
Logical value. If
TRUE
then use year in the original data as the base year to recode the geographical codes. Default isFALSE
and use all available codes in geo codebook- control
Logical value.
TRUE
if the file has been controlled for possible errors- wide
Column(s) from reshape wide
See also
Other aggregate functions:
get_aggregate()
Examples
if (FALSE) { # \dontrun{
# To aggregate source data with enumeration area codes ie. grunnkrets, to
# manucipaltiy ie. kommune
dt <- make_file("BEFOLKNING")
DT <- do_aggregate(dt, source = "grunnkrets", level = "kommune")
} # }