From 7803d1ada9aa952bada0a2d1730a05f4437645e1 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer <reinhold@kainhofer.com> Date: Tue, 17 Aug 2021 01:15:00 +0200 Subject: [PATCH] add pensionTable.NA to indicate an empty pension table --- R/pensionTable.R | 17 ++++++++++++++ .../extdata/PensionTables_Austria_AVOe1999P.R | 21 +++++++++-------- .../extdata/PensionTables_Austria_AVOe2008P.R | 23 ++++++++++--------- .../extdata/PensionTables_Austria_AVOe2018P.R | 11 +++++---- .../PensionTables_Austria_EttlPagler.R | 2 ++ 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/R/pensionTable.R b/R/pensionTable.R index 4472671..620555b 100644 --- a/R/pensionTable.R +++ b/R/pensionTable.R @@ -90,6 +90,16 @@ pensionTable = setClass( probs.arrange = "function" ), prototype = list( + qx = mortalityTable.NA, + ix = mortalityTable.NA, + qix = mortalityTable.NA, + rx = mortalityTable.NA, + apx = mortalityTable.NA, + qpx = mortalityTable.NA, + hx = mortalityTable.NA, + qwy = mortalityTable.NA, + yx = mortalityTable.NA, + qgx = mortalityTable.NA, invalids.retire = FALSE, probs.arrange = pensionTableProbArrange ), @@ -267,6 +277,13 @@ setMethod("periodTransitionProbabilities", "pensionTable", }) +#' Empty pension table indicating NA +#' +#' @export +pensionTable.NA = pensionTable() + + + if (FALSE) { pensionTables.load("Austria_AVOe2008P") transitionProbabilities(AVOe2008P.male, YOB = 1977, as.data.frame = FALSE) diff --git a/inst/extdata/PensionTables_Austria_AVOe1999P.R b/inst/extdata/PensionTables_Austria_AVOe1999P.R index 72c946e..0c18fa9 100644 --- a/inst/extdata/PensionTables_Austria_AVOe1999P.R +++ b/inst/extdata/PensionTables_Austria_AVOe1999P.R @@ -7,6 +7,17 @@ stopifnot(require(methods), require(utils), require(MortalityTables), require(re # Pension Table AVÖ 1999P ---- ############################################################################### # +AVOe1999P = array( + data = c(pensionTable.NA), + dim = c(2, 2), + dimnames = list(Geschlecht = c("m", "w"), Bestand = c("Angestellte", "Mischbestand")) +) +AVOe1999PK = array( + data = c(pensionTable.NA), + dim = c(2, 2), + dimnames = list(Geschlecht = c("m", "w"), Bestand = c("Angestellte", "Mischbestand")) +) + if (is.null(getOption("MortalityTables.AVOe1999P"))) { message("The pension table AVÖ 1999P requires the Excel file 'Austria_Pensions_AVOe1999P.xlsx'. Please set its path with options(\"MortalityTables.AVOe1999P\" = \"/path/to/Austria_Pensions_AVOe1999P.xlsx\").") } else { @@ -106,16 +117,6 @@ AVOe1999P.generate = function(tab, name="P", collar = "Angestellte") { # Die Tafel als Array ---- ############################################################################## # -AVOe1999P = array( - data = c(mortalityTable.NA), - dim = c(2, 2), - dimnames = list(Geschlecht = c("m", "w"), Bestand = c("Angestellte", "Mischbestand")) -) -AVOe1999PK = array( - data = c(mortalityTable.NA), - dim = c(2, 2), - dimnames = list(Geschlecht = c("m", "w"), Bestand = c("Angestellte", "Mischbestand")) -) AVOe1999P[, "Angestellte"] = AVOe1999P.generate(tab = "Angestellte", "P", collar = "Angestellte") AVOe1999P[, "Mischbestand"] = AVOe1999P.generate(tab = "Arbeiter+Angestellte", "P Arb./Ang.", collar = "Mischbestand") AVOe1999PK[, "Angestellte"] = AVOe1999P.generate(tab = "Angestellte PK", "PK", collar = "Angestellte") diff --git a/inst/extdata/PensionTables_Austria_AVOe2008P.R b/inst/extdata/PensionTables_Austria_AVOe2008P.R index 34cc76a..d3dd771 100644 --- a/inst/extdata/PensionTables_Austria_AVOe2008P.R +++ b/inst/extdata/PensionTables_Austria_AVOe2008P.R @@ -7,6 +7,18 @@ stopifnot(require(methods), require(utils), require(MortalityTables), require(re # AVÖ 2008P exact (Male, Female) ############################################################################### +AVOe2008P = array( + data = c(pensionTable.NA), + dim = c(2, 2), + dimnames = list(Geschlecht = c("m", "w"), Bestand = c("Angestellte", "Mischbestand")) +) +AVOe2008PK = array( + data = c(pensionTable.NA), + dim = c(2, 2), + dimnames = list(Geschlecht = c("m", "w"), Bestand = c("Angestellte", "Mischbestand")) +) + + if (is.null(getOption("MortalityTables.AVOe2008P"))) { message("The pension table AVÖ 1999P requires the Excel file 'Austria_Pensions_AVOe2008P.xlsx'. Please set its path with options(\"MortalityTables.AVOe2008P\" = \"/path/to/Austria_Pensions_AVOe2008P.xlsx\").") } else { @@ -183,17 +195,6 @@ AVOe2008P.generate = function(tab, name = "P", collar = "Angestellte") { # Die Tafel als Array ---- ############################################################################## # -AVOe2008P = array( - data = c(mortalityTable.NA), - dim = c(2, 2), - dimnames = list(Geschlecht = c("m", "w"), Bestand = c("Angestellte", "Mischbestand")) -) -AVOe2008PK = array( - data = c(mortalityTable.NA), - dim = c(2, 2), - dimnames = list(Geschlecht = c("m", "w"), Bestand = c("Angestellte", "Mischbestand")) -) - AVOe2008P[, "Angestellte"] = AVOe2008P.generate("Angestellte", "P", collar = "Angestellte") AVOe2008P[, "Mischbestand"] = AVOe2008P.generate("Arbeiter+Angestellte", "P Arb./Ang.", collar = "Mischbestand") AVOe2008PK[, "Angestellte"] = AVOe2008P.generate("Angestellte PK", "P", collar = "Angestellte") diff --git a/inst/extdata/PensionTables_Austria_AVOe2018P.R b/inst/extdata/PensionTables_Austria_AVOe2018P.R index 145b860..d650fe4 100644 --- a/inst/extdata/PensionTables_Austria_AVOe2018P.R +++ b/inst/extdata/PensionTables_Austria_AVOe2018P.R @@ -9,15 +9,16 @@ stopifnot(require(methods), require(utils), require(MortalityTables), require(dp # Pension Table AVÖ 2018-P ---- ############################################################################### # +AVOe2018P = array( + data = c(pensionTable.NA), + dim = c(3, 2, 2), + dimnames = list(Geschlecht = c("m", "w", "u"), Bestand = c("Angestellte", "Mischbestand"), Invalidisierung = c("IP", "IPRG")) +) + if (is.null(getOption("MortalityTables.AVOe2018PAng")) && is.null(getOption("MortalityTables.AVOe2018PMisch"))) { message("The pension table AVOe2018P requires the Excel files 'AVOe2018P_Pensionstafeln_Angestellte.xlsx' or 'AVOe2018P_Pensionstafeln_Mischbestand.xlsx'. Please set the paths to them with options(\"MortalityTables.AVOe2018PAng\" = \"/path/to/AVOe2018P_Pensionstafeln_Angestellte.xlsx\") and options(\"MortalityTables.AVOe2018PMisch\" = \"..\").") } else { - AVOe2018P = array( - data = c(mortalityTable.NA), - dim = c(3, 2, 2), - dimnames = list(Geschlecht = c("m", "w", "u"), Bestand = c("Angestellte", "Mischbestand"), Invalidisierung = c("IP", "IPRG")) - ) #------------------------------------------------------------------------------- - # Functions to load the tables (raw base tables and trend) and the additional info ---- diff --git a/inst/extdata/PensionTables_Austria_EttlPagler.R b/inst/extdata/PensionTables_Austria_EttlPagler.R index 72553aa..63d63f8 100644 --- a/inst/extdata/PensionTables_Austria_EttlPagler.R +++ b/inst/extdata/PensionTables_Austria_EttlPagler.R @@ -10,6 +10,8 @@ stopifnot(require(methods), require(utils), require(MortalityTables), require(re if (is.null(getOption("MortalityTables.EttlPagler"))) { message("The pension table EttlPagler requires the Excel file 'Austria_Pensions_EttlPagler.xlsx'. Please set its path with options(\"MortalityTables.EttlPagler\" = \"/path/to/Austria_Pensions_EttlPagler.xlsx\").") + EttlPagler = c(m = pensionTable.NA, w = pensionTable.NA) + } else { ############################################################################### -- GitLab