-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Consider the following simple example:
library(data.table)
dat <- merge(reshape2::melt(demography::fr.mort$rate$total),
reshape2::melt(demography::fr.mort$pop$total), by = c("Var1", "Var2"))
dat$age <- as.numeric(ifelse(dat$Var1 == "110+", 110, as.character(levels(dat$Var1))[dat$Var1]))
dat$agecut <- cut(dat$age, c(0:4, seq(5, 95, 5), Inf), right = FALSE,
labels = c((0:4) + 0.5, seq(5, 90, 5) + 2.5, 100))
dat$deaths <- dat$value.x * dat$value.y
dat <- as.data.table(dat)
dat <- dat[, .(mort = sum(deaths)/sum(value.y)) , .(period = Var2, agecut)]
dat$age <- as.numeric(levels(dat$agecut))[dat$agecut]
APCtools::plot_APCheatmap(dat, y_var = "mort")
I originally thought that the problem is due to an automatic binning, so it can be solved by overriding it manually:
APCtools::plot_APCheatmap(dat, y_var = "mort", bin_heatmapGrid_list = list(age = c(0:4, seq(5, 95, 5))))
But, as the above example shows, it didn't solve to problem. (Actually, it made it worse, now the mortality in the 0-1 year age bracket seems to be unchanged over the entire period!)
Metadata
Metadata
Assignees
Labels
No labels