Skip to contents

Aggregates mortality data to a weekly basis. Where the percentiles and number of deaths obtained after every week up to n_week is also given. For more details see the help vignette:

Usage

nowcast_aggregate(data, aggregation_date, n_week, pop_data = NULL)

Arguments

data

Dataset containing doe (Date of event), dor (Date of registation) and location_code. The columns must have these exact names.

aggregation_date

Date of aggregation

n_week

Number of weeks to calculate the percentage of the total registraations. Must be larger og equal to 2 amd smaller than the total number of weeks in the dataset.

pop_data

Population data, must contain a column called pop with the population data and a column with year and possibly week.

Value

Aggregated dataset with the percentiles of registered events within the last 52 weeks

Details

vignette("intro", package="nowcast")

Examples


data <- nowcast::data_fake_nowcasting_raw
data[doe < as.Date("2019-01-01")]
#>               doe        dor location_code
#>     1: 2018-01-01 2018-01-10         norge
#>     2: 2018-01-01 2018-01-07         norge
#>     3: 2018-01-01 2018-01-05         norge
#>     4: 2018-01-01 2018-01-07         norge
#>     5: 2018-01-01 2018-01-05         norge
#>    ---                                    
#> 42115: 2018-12-31 2019-01-08         norge
#> 42116: 2018-12-31 2019-01-11         norge
#> 42117: 2018-12-31 2019-01-06         norge
#> 42118: 2018-12-31 2019-01-04         norge
#> 42119: 2018-12-31 2019-01-05         norge
aggregation_date <- as.Date("2020-01-01")
n_week <- 6

data_aggregated <- nowcast_aggregate(data, aggregation_date, n_week)
#> 1 done 
#> 2 done 
#> 3 done 
#> 4 done 
#> 5 done 
#> 6 done