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

Docs: Clean up documentation of contractGrid

parent d19d72b9
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
#' contract object. #' contract object.
#' #'
#' To create the human-readable row-/columnnames of the resulting array, #' To create the human-readable row-/columnnames of the resulting array,
#' the function [make.] #' the function [makeContractGridDimname()] for each value of the axes, allowing
#' human-readable representations e.g. of a tariff or a mortality table as
#' the dimension label.
#' #'
#' #'
#' #'
...@@ -70,39 +72,53 @@ contractGrid = function(axes = list(age = seq(20, 60, 10), policyPeriod = seq(5, ...@@ -70,39 +72,53 @@ contractGrid = function(axes = list(age = seq(20, 60, 10), policyPeriod = seq(5,
array(vals, dim = sapply(axes, length), dimnames = dimnames) array(vals, dim = sapply(axes, length), dimnames = dimnames)
} }
#' @describeIn makeContractGridDimname Create a dimensional name for an [InsuranceTarif] object # describeIn makeContractGridDimname Create a dimensional name for an [InsuranceTarif] object
#' @export #' @export
makeContractGridDimname.InsuranceTarif = function(value) { value$name } makeContractGridDimname.InsuranceTarif = function(value) { value$name }
#' @describeIn makeContractGridDimname Create a dimensional name for an R6 object (using its \code{name} field) # describeIn makeContractGridDimname Create a dimensional name for an R6 object (using its \code{name} field)
#' @export #' @export
makeContractGridDimname.R6 = function(value) { value$name } makeContractGridDimname.R6 = function(value) { value$name }
#' @describeIn makeContractGridDimname Create a dimensional name for an [mortalityTable] object # describeIn makeContractGridDimname Create a dimensional name for an [mortalityTable] object
#' @export #' @export
makeContractGridDimname.mortalityTable = function(value) { value@name } makeContractGridDimname.mortalityTable = function(value) { value@name }
#' @describeIn makeContractGridDimname Create a dimensional name for a numeric parameter value # describeIn makeContractGridDimname Create a dimensional name for a numeric parameter value
#' @export #' @export
makeContractGridDimname.numeric = function(value) { value } makeContractGridDimname.numeric = function(value) { value }
#' @describeIn makeContractGridDimname Create a dimensional name for a numeric parameter value # describeIn makeContractGridDimname Create a dimensional name for a numeric parameter value
#' @export #' @export
makeContractGridDimname.double = function(value) { value } makeContractGridDimname.double = function(value) { value }
#' @describeIn makeContractGridDimname Create a dimensional name for an object that can be directly used as a human-readable row-/columnname # describeIn makeContractGridDimname Create a dimensional name for an object that can be directly used as a human-readable row-/columnname
#' @export #' @export
makeContractGridDimname.default = function(value) { value } makeContractGridDimname.default = function(value) { value }
#' Create human-readable labels for the dimensions in a [contractGrid()] #' Create human-readable labels for the dimensions in a [contractGrid()]
#' #'
#' The funciton \code{makeContractGridDimname} generates a short, human-readable #' The function \code{makeContractGridDimname} generates a short, human-readable
#' dimension label for the object passed as \code{value}, to be used in [contractGrid]. #' dimension label for the entries along the axes of a [contractGrid()].
#' The default is to use the \code{value} unchanged as the row-/columnname, but #' The default is to use the \code{value} unchanged as the row-/columnname, but
#' for some parameter values (like a [InsuranceTarif] or [mortalityTable]) #' for some parameter values (like a [InsuranceTarif] or [mortalityTable])
#' a custom method of this function is needed to create the (short) human-readable #' a custom method of this function is needed to create the (short) human-readable
#' representation for the axes in the grid. #' representation for the axes in the grid.
#'
#' @param value the value along the axis, for which a name should be generated #' @param value the value along the axis, for which a name should be generated
# describeIn makeContractGridDimname Create a short, human-readable dimensional name for an object (default S3 method) #' @describeIn makeContractGridDimname Create a short, human-readable dimensional name for an object (default S3 method)
#' @examples
#' library(MortalityTables)
#' mortalityTables.load("Austria_Census")
#'
#' makeContractGridDimname(mort.AT.census.2011.unisex)
#'
#' makeContractGridDimnames(axes = list(
#' age = seq(30,60,10),
#' mortalityTable = c(mort.AT.census.2011.unisex, mort.AT.census.2011.male, mort.AT.census.2011.female))
#' )
#' @export #' @export
makeContractGridDimname = function(value) { UseMethod("makeContractGridDimname", value) } makeContractGridDimname = function(value) { UseMethod("makeContractGridDimname", value) }
#' Generate proper dimnames for all entries of the axes of a [contractGrid()]
#' @description The function \code{makeContractGridDimnames} generate proper
#' dimnames for all entries of the axes of a [contractGrid()] by calling
#' \code{makeContractGridDimname} on each of the axes' values
#' @param axes the axes with all names, for which a name should be generated #' @param axes the axes with all names, for which a name should be generated
#' @describeIn makeContractGridDimnames Generate proper dimnames for all entries of the axes of a [contractGrid()] #' @describeIn makeContractGridDimname Generate proper dimnames for all entries of the axes of a [contractGrid()]
#' @export #' @export
makeContractGridDimnames = function(axes) { makeContractGridDimnames = function(axes) {
lapply(axes, function(axis) { lapply(axis, makeContractGridDimname); } ) lapply(axes, function(axis) { lapply(axis, makeContractGridDimname); } )
...@@ -134,11 +150,11 @@ makeContractGridDimnames = function(axes) { ...@@ -134,11 +150,11 @@ makeContractGridDimnames = function(axes) {
#' #'
#' @rdname contractGrid #' @rdname contractGrid
#' @export #' @export
contractGridPremium = function(contractGrid = NULL, premium="written", .fun = function(c) { c[[1]]$Values$premiums[[premium]] }, ...) { contractGridPremium = function(contractGrid = NULL, premium="written", .fun = function(cntr) { cntr$Values$premiums[[premium]] }, ...) {
if (missing(contractGrid) || is.null(contractGrid)) { if (missing(contractGrid) || is.null(contractGrid)) {
contractGrid = contractGrid(...) contractGrid = contractGrid(...)
} }
apply(contractGrid, 1:length(dim(contractGrid)), .fun) apply(contractGrid, 1:length(dim(contractGrid)), function(c) { .fun(c[[1]])})
} }
...@@ -15,7 +15,7 @@ contractGrid( ...@@ -15,7 +15,7 @@ contractGrid(
contractGridPremium( contractGridPremium(
contractGrid = NULL, contractGrid = NULL,
premium = "written", premium = "written",
.fun = function(c) { c[[1]]$Values$premiums[[premium]] }, .fun = function(cntr) { cntr$Values$premiums[[premium]] },
... ...
) )
} }
...@@ -68,7 +68,9 @@ is then passed to the \code{\link[=InsuranceContract$new]{InsuranceContract$new( ...@@ -68,7 +68,9 @@ is then passed to the \code{\link[=InsuranceContract$new]{InsuranceContract$new(
contract object. contract object.
To create the human-readable row-/columnnames of the resulting array, To create the human-readable row-/columnnames of the resulting array,
the function \link{make.} the function \code{\link[=makeContractGridDimname]{makeContractGridDimname()}} for each value of the axes, allowing
human-readable representations e.g. of a tariff or a mortality table as
the dimension label.
} }
\examples{ \examples{
# TODO # TODO
......
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/contractGrid.R % Please edit documentation in R/contractGrid.R
\name{makeContractGridDimname.InsuranceTarif} \name{makeContractGridDimname}
\alias{makeContractGridDimname.InsuranceTarif}
\alias{makeContractGridDimname.R6}
\alias{makeContractGridDimname.mortalityTable}
\alias{makeContractGridDimname.numeric}
\alias{makeContractGridDimname.double}
\alias{makeContractGridDimname.default}
\alias{makeContractGridDimname} \alias{makeContractGridDimname}
\alias{makeContractGridDimnames}
\title{Create human-readable labels for the dimensions in a \code{\link[=contractGrid]{contractGrid()}}} \title{Create human-readable labels for the dimensions in a \code{\link[=contractGrid]{contractGrid()}}}
\usage{ \usage{
\method{makeContractGridDimname}{InsuranceTarif}(value)
\method{makeContractGridDimname}{R6}(value)
\method{makeContractGridDimname}{mortalityTable}(value)
\method{makeContractGridDimname}{numeric}(value)
\method{makeContractGridDimname}{double}(value)
\method{makeContractGridDimname}{default}(value)
makeContractGridDimname(value) makeContractGridDimname(value)
makeContractGridDimnames(axes)
} }
\arguments{ \arguments{
\item{value}{the value along the axis, for which a name should be generated} \item{value}{the value along the axis, for which a name should be generated}
\item{axes}{the axes with all names, for which a name should be generated}
} }
\description{ \description{
The funciton \code{makeContractGridDimname} generates a short, human-readable The function \code{makeContractGridDimname} generates a short, human-readable
dimension label for the object passed as \code{value}, to be used in \link{contractGrid}. dimension label for the entries along the axes of a \code{\link[=contractGrid]{contractGrid()}}.
The default is to use the \code{value} unchanged as the row-/columnname, but The default is to use the \code{value} unchanged as the row-/columnname, but
for some parameter values (like a \link{InsuranceTarif} or \link{MortalityTable}) for some parameter values (like a \link{InsuranceTarif} or \link{mortalityTable})
a custom method of this function is needed to create the (short) human-readable a custom method of this function is needed to create the (short) human-readable
representation for the axes in the grid. representation for the axes in the grid.
The function \code{makeContractGridDimnames} generate proper
dimnames for all entries of the axes of a \code{\link[=contractGrid]{contractGrid()}} by calling
\code{makeContractGridDimname} on each of the axes' values
} }
\section{Methods (by class)}{ \section{Functions}{
\itemize{ \itemize{
\item \code{InsuranceTarif}: Create a dimensional name for an \link{InsuranceTarif} object \item \code{makeContractGridDimname}: Create a short, human-readable dimensional name for an object (default S3 method)
\item \code{R6}: Create a dimensional name for an R6 object (using its \code{name} field)
\item \code{mortalityTable}: Create a dimensional name for an \link{MortalityTable} object
\item \code{numeric}: Create a dimensional name for a numeric parameter value \item \code{makeContractGridDimnames}: Generate proper dimnames for all entries of the axes of a \code{\link[=contractGrid]{contractGrid()}}
}}
\item \code{double}: Create a dimensional name for a numeric parameter value \examples{
library(MortalityTables)
mortalityTables.load("Austria_Census")
\item \code{default}: Create a dimensional name for an object that can be directly used as a human-readable row-/columnname makeContractGridDimname(mort.AT.census.2011.unisex)
}}
makeContractGridDimnames(axes = list(
age = seq(30,60,10),
mortalityTable = c(mort.AT.census.2011.unisex, mort.AT.census.2011.male, mort.AT.census.2011.female))
)
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/contractGrid.R
\name{makeContractGridDimnames}
\alias{makeContractGridDimnames}
\title{Generate proper dimnames for all entries of the axes of a \code{\link[=contractGrid]{contractGrid()}}}
\usage{
makeContractGridDimnames(axes)
}
\arguments{
\item{axes}{the axes with all names, for which a name should be generated}
}
\description{
Generate proper dimnames for all entries of the axes of a \code{\link[=contractGrid]{contractGrid()}}
}
\section{Functions}{
\itemize{
\item \code{makeContractGridDimnames}: Generate proper dimnames for all entries of the axes of a \code{\link[=contractGrid]{contractGrid()}}
}}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment