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

add function mT.getName to retrieve a table's name (also from arrays of tables)

parent 7803d1ad
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@ export(mT.extrapolateTrendExp)
export(mT.fillAges)
export(mT.fitExtrapolationLaw)
export(mT.getDimInfo)
export(mT.getName)
export(mT.scaleProbs)
export(mT.setDimInfo)
export(mT.setName)
......
......@@ -108,6 +108,32 @@ mT.setName = function(table, name) {
table
}
#' Retrieves the name of the given mortality table or the list/table/array of mortalityTables
#'
#' @param table A life table object (instance of a \code{mortalityTable} class) or a list, table or array of mortalityTable objects
#'
#' @examples
#' mortalityTables.load("Austria_Annuities")
#' mT.getName(AVOe2005R.male)
#'
#' @export
mT.getName = function(table) {
if (is.array(table)) {
return(array(
lapply(table, mT.getName),
dim = dim(table), dimnames = dimnames(table))
)
} else if (is.list(table)) {
return(lapply(table, mT.getName))
} else if (is.na(c(table))) {
return(table)
}
if (!is(table, "mortalityTable"))
stop("First argument must be a mortalityTable or a list of mortalityTable objects.")
table@name
}
#' Restrict/expand a mortalityTable to certain ages
#'
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utilityFunctions.R
\name{mT.getName}
\alias{mT.getName}
\title{Retrieves the name of the given mortality table or the list/table/array of mortalityTables}
\usage{
mT.getName(table)
}
\arguments{
\item{table}{A life table object (instance of a \code{mortalityTable} class) or a list, table or array of mortalityTable objects}
}
\description{
Retrieves the name of the given mortality table or the list/table/array of mortalityTables
}
\examples{
mortalityTables.load("Austria_Annuities")
mT.getName(AVOe2005R.male)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment