Skip to contents

Aggregates mortality data to a weekly basis. Where the percentiles and number of mortalities 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="attrib")

Examples


data <- attrib::data_fake_nowcasting_nation_raw
data[doe < as.Date("2019-01-01")]
#>               doe        dor location_code
#>     1: 2018-01-01 2018-01-18    nation_nor
#>     2: 2018-01-01 2018-01-27    nation_nor
#>     3: 2018-01-01 2018-01-22    nation_nor
#>     4: 2018-01-01 2018-01-16    nation_nor
#>     5: 2018-01-01 2018-01-29    nation_nor
#>    ---                                    
#> 32851: 2018-12-31 2019-01-19    nation_nor
#> 32852: 2018-12-31 2019-01-14    nation_nor
#> 32853: 2018-12-31 2019-01-30    nation_nor
#> 32854: 2018-12-31 2019-01-28    nation_nor
#> 32855: 2018-12-31 2019-01-21    nation_nor
aggregation_date <- as.Date("2020-01-01")
n_week <- 3

data_aggregated <- nowcast_aggregate(data, aggregation_date, n_week)