Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
R - Mortality Tables
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
R
R - Mortality Tables
Commits
d5575c40
Commit
d5575c40
authored
4 years ago
by
Reinhold Kainhofer
Browse files
Options
Downloads
Patches
Plain Diff
add function mT.setSlot to set any slot within a mortality table
parent
6bf5cee6
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
NAMESPACE
+1
-0
1 addition, 0 deletions
NAMESPACE
R/utilityFunctions.R
+60
-0
60 additions, 0 deletions
R/utilityFunctions.R
man/mT.setSlot.Rd
+46
-0
46 additions, 0 deletions
man/mT.setSlot.Rd
with
107 additions
and
0 deletions
NAMESPACE
+
1
−
0
View file @
d5575c40
...
...
@@ -74,6 +74,7 @@ exportMethods(getPeriodTable)
exportMethods(lifeTable)
exportMethods(mT.cleanup)
exportMethods(mT.round)
exportMethods(mT.setSlot)
exportMethods(mortalityImprovement)
exportMethods(periodDeathProbabilities)
exportMethods(periodTransitionProbabilities)
...
...
This diff is collapsed.
Click to expand it.
R/utilityFunctions.R
+
60
−
0
View file @
d5575c40
...
...
@@ -951,3 +951,63 @@ pT.recalculateTotalMortality = function(object, ...) {
object
}
#' Set a certain slot of the mortality tables (or of each element of the list of tables)
#'
#' The function mt.setSlot adds the given slot to all mortalityTable objects.
#'
#' @param object The mortalityTable object to be modified (or a list / array of mortalityTable object)
#' @param slot the desired slot to set
#' @param value the value for the slot
#'
#' @examples
#' mortalityTables.load("Austria_Census")
#' # Add 10-year selection factors to the population mortality
#' mort.AT.census.2011.male.select = mT.setSlot(mort.AT.census.2011.male, "selectionFactors", 1:10/10)
#'
#' @exportMethod mT.setSlot
setGeneric
(
"mT.setSlot"
,
function
(
object
,
slot
,
value
=
NULL
)
standardGeneric
(
"mT.setSlot"
));
#' @describeIn mT.setSlot Set a slot for the given mortalityTable
setMethod
(
"mT.setSlot"
,
"mortalityTable"
,
function
(
object
,
slot
,
value
=
NULL
)
{
slot
(
object
,
slot
)
<-
value
object
})
#' @describeIn mT.setSlot Set a slot for the mortalityTables stored in an array
setMethod
(
"mT.setSlot"
,
"array"
,
function
(
object
,
slot
,
value
=
NULL
)
{
array
(
lapply
(
object
,
mT.setSlot
,
slot
=
slot
,
value
=
value
),
dim
=
dim
(
object
),
dimnames
=
dimnames
(
object
))
})
#' @describeIn mT.setSlot Set a slot for the given mortalityTables stored in a list
setMethod
(
"mT.setSlot"
,
"list"
,
function
(
object
,
slot
,
value
=
NULL
)
{
lapply
(
object
,
mT.setSlot
,
slot
=
slot
,
value
=
value
)
})
#' @describeIn mT.setSlot Set a slot for all components of a pensionTable
setMethod
(
"mT.setSlot"
,
"pensionTable"
,
function
(
object
,
slot
,
value
=
NULL
)
{
object
@
qx
=
mT.setSlot
(
object
@
qx
,
slot
=
slot
,
value
=
value
)
object
@
ix
=
mT.setSlot
(
object
@
ix
,
slot
=
slot
,
value
=
value
)
object
@
qix
=
mT.setSlot
(
object
@
qix
,
slot
=
slot
,
value
=
value
)
object
@
rx
=
mT.setSlot
(
object
@
rx
,
slot
=
slot
,
value
=
value
)
object
@
apx
=
mT.setSlot
(
object
@
apx
,
slot
=
slot
,
value
=
value
)
object
@
qpx
=
mT.setSlot
(
object
@
qpx
,
slot
=
slot
,
value
=
value
)
object
@
hx
=
mT.setSlot
(
object
@
hx
,
slot
=
slot
,
value
=
value
)
object
@
qwy
=
mT.setSlot
(
object
@
qwy
,
slot
=
slot
,
value
=
value
)
object
@
qgx
=
mT.setSlot
(
object
@
qgx
,
slot
=
slot
,
value
=
value
)
object
})
#' @describeIn mT.setSlot Empty dummy function that simply returns NULL
setMethod
(
"mT.setSlot"
,
"NULL"
,
function
(
object
,
slot
,
value
=
NULL
)
{
NULL
})
This diff is collapsed.
Click to expand it.
man/mT.setSlot.Rd
0 → 100644
+
46
−
0
View file @
d5575c40
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utilityFunctions.R
\name{mT.setSlot}
\alias{mT.setSlot}
\alias{mT.setSlot,mortalityTable-method}
\alias{mT.setSlot,array-method}
\alias{mT.setSlot,list-method}
\alias{mT.setSlot,pensionTable-method}
\alias{mT.setSlot,NULL-method}
\title{Set a certain slot of the mortality tables (or of each element of the list of tables)}
\usage{
mT.setSlot(object, slot, value = NULL)
\S4method{mT.setSlot}{mortalityTable}(object, slot, value = NULL)
\S4method{mT.setSlot}{array}(object, slot, value = NULL)
\S4method{mT.setSlot}{list}(object, slot, value = NULL)
\S4method{mT.setSlot}{pensionTable}(object, slot, value = NULL)
\S4method{mT.setSlot}{`NULL`}(object, slot, value = NULL)
}
\arguments{
\item{object}{The mortalityTable object to be modified (or a list / array of mortalityTable object)}
\item{slot}{the desired slot to set}
\item{value}{the value for the slot}
}
\description{
The function mt.setSlot adds the given slot to all mortalityTable objects.
}
\section{Methods (by class)}{
\itemize{
\item \code{mortalityTable}: Set a slot for the given mortalityTable
\item \code{array}: Set a slot for the mortalityTables stored in an array
\item \code{list}: Set a slot for the given mortalityTables stored in a list
\item \code{pensionTable}: Set a slot for all components of a pensionTable
\item \code{NULL}: Empty dummy function that simply returns NULL
}}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment