Commit 1b113239 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

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

parent cab5dffa
......@@ -32,6 +32,7 @@ export(mortalityTable.trendProjection)
export(mortalityTable.zeroes)
export(mortalityTables.list)
export(mortalityTables.load)
export(pT.getSubTable)
export(pensionTable)
export(pensionTables.list)
export(pensionTables.load)
......
......@@ -284,3 +284,22 @@ mT.setDimInfo = function(table, ..., append = TRUE) {
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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment