Skip to content
Snippets Groups Projects
Commit 1b113239 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Add pT.getSubTable to extract sub-tables of pensionTable objects

parent cab5dffa
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,7 @@ export(mortalityTable.trendProjection) ...@@ -32,6 +32,7 @@ export(mortalityTable.trendProjection)
export(mortalityTable.zeroes) export(mortalityTable.zeroes)
export(mortalityTables.list) export(mortalityTables.list)
export(mortalityTables.load) export(mortalityTables.load)
export(pT.getSubTable)
export(pensionTable) export(pensionTable)
export(pensionTables.list) export(pensionTables.list)
export(pensionTables.load) export(pensionTables.load)
......
...@@ -284,3 +284,22 @@ mT.setDimInfo = function(table, ..., append = TRUE) { ...@@ -284,3 +284,22 @@ mT.setDimInfo = function(table, ..., append = TRUE) {
table table
} }
#' @export
pT.getSubTable = function(table, subtable = "qx") {
if (is.array(table)) {
return(array(
lapply(table, pT.getSubTable, subtable = subtable),
dim = dim(table), dimnames = dimnames(table))
)
} else if (is.list(table)) {
return(lapply(table, pT.getSubTable, subtable = subtable))
}
if (!is(table, "pensionTable"))
stop("First argument must be a pensionTable or a list of pensionTable objects.")
if (.hasSlot(table, subtable))
slot(table, subtable)
else
NULL
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment