From d8adcdc72ffc285811bef08652d80c39cbc60095 Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Mon, 11 Sep 2017 00:21:52 +0000
Subject: [PATCH] ageShift: Return NA for mortalityTables without age shift

---
 R/ageShift.R    | 8 ++++++++
 man/ageShift.Rd | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/R/ageShift.R b/R/ageShift.R
index edefc8b..ec81c11 100644
--- a/R/ageShift.R
+++ b/R/ageShift.R
@@ -12,10 +12,18 @@ NULL
 #' ageShift(AVOe2005R.male.av, YOB=1910)
 #' ageShift(AVOe2005R.male.av, YOB=1955)
 #' ageShift(AVOe2005R.male.av, YOB=2010)
+#' # A table with trend does NOT have any age shift, so NA is returned:
+#' ageShift(AVOe2005R.male, YOB=1910)
 #'
 #' @exportMethod ageShift
 setGeneric("ageShift", function(object, YOB=1975, ...) standardGeneric("ageShift"));
 
+#' @describeIn ageShift Age shifts apply only to mortalityTagle.ageShift, so
+#'             all other tables return NA.
+setMethod("ageShift", "mortalityTable", function(object, YOB, ...) {
+    NA
+})
+
 #' @describeIn ageShift Return the age shift of the age-shifted life table
 #'                      given the birth year
 setMethod("ageShift",
diff --git a/man/ageShift.Rd b/man/ageShift.Rd
index 6692a38..e144406 100644
--- a/man/ageShift.Rd
+++ b/man/ageShift.Rd
@@ -3,11 +3,14 @@
 \docType{methods}
 \name{ageShift}
 \alias{ageShift}
+\alias{ageShift,mortalityTable-method}
 \alias{ageShift,mortalityTable.ageShift-method}
 \title{Return the age shift of the age-shifted life table given the birth year}
 \usage{
 ageShift(object, YOB = 1975, ...)
 
+\S4method{ageShift}{mortalityTable}(object, YOB = 1975, ...)
+
 \S4method{ageShift}{mortalityTable.ageShift}(object, YOB = 1975, ...)
 }
 \arguments{
@@ -22,6 +25,9 @@ Return the age shift of the age-shifted life table given the birth year
 }
 \section{Methods (by class)}{
 \itemize{
+\item \code{mortalityTable}: Age shifts apply only to mortalityTagle.ageShift, so
+all other tables return NA.
+
 \item \code{mortalityTable.ageShift}: Return the age shift of the age-shifted life table
 given the birth year
 }}
@@ -31,5 +37,7 @@ mortalityTables.load("Austria_Annuities")
 ageShift(AVOe2005R.male.av, YOB=1910)
 ageShift(AVOe2005R.male.av, YOB=1955)
 ageShift(AVOe2005R.male.av, YOB=2010)
+# A table with trend does NOT have any age shift, so NA is returned:
+ageShift(AVOe2005R.male, YOB=1910)
 
 }
-- 
GitLab