From 6ff0a6f1e787684f11df4c1c83c011581ac3ddca Mon Sep 17 00:00:00 2001
From: Reinhold Kainhofer <reinhold@kainhofer.com>
Date: Sun, 10 Sep 2017 21:02:41 +0000
Subject: [PATCH] Add trend=TRUE parameter to plot.mortalityTable

This new argument allows the generic plog.mortalityTable to call plotMortalityTrend, if not set (or set to anything other than TRUE), the mortalities / death probabilities are plotted.
---
 R/plot.mortalityTable.R    | 11 ++++++++---
 man/plot.mortalityTable.Rd |  5 ++++-
 man/plotMortalityTrend.Rd  |  2 +-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/R/plot.mortalityTable.R b/R/plot.mortalityTable.R
index 69bdbc1..edfbd41 100644
--- a/R/plot.mortalityTable.R
+++ b/R/plot.mortalityTable.R
@@ -30,6 +30,9 @@
 #' @param reference The reference table that determines the 100\% values.
 #'                  If not given, the absolute mortality values are
 #'                  compared and plotted on a log-linear scale.
+#' @param trend If set to \code{TRUE}, the function \code{\link{plotMortalityTrend}}
+#'              is used to plot the trends of the given tables.
+#'
 #'
 #' @examples
 #' # Load the Austrian census data
@@ -55,9 +58,11 @@
 #'
 #' @import scales
 #' @export
-plot.mortalityTable = function(x, ..., reference=NULL) {
-    if (!missing(reference) && !is.null(reference)) {
-        plotMortalityTableComparisons(x, ..., reference=reference)
+plot.mortalityTable = function(x, ..., reference = NULL, trend = FALSE) {
+    if (!missing(trend) && isTRUE(trend)) {
+        plotMortalityTrend(x, ..., reference = reference)
+    } else if (!missing(reference) && !is.null(reference)) {
+        plotMortalityTableComparisons(x, ..., reference = reference)
     } else {
         plotMortalityTables(x, ...)
     }
diff --git a/man/plot.mortalityTable.Rd b/man/plot.mortalityTable.Rd
index e7a3363..a1c79aa 100644
--- a/man/plot.mortalityTable.Rd
+++ b/man/plot.mortalityTable.Rd
@@ -4,7 +4,7 @@
 \alias{plot.mortalityTable}
 \title{Plot multiple mortality tables (life tables) in one plot}
 \usage{
-\method{plot}{mortalityTable}(x, ..., reference = NULL)
+\method{plot}{mortalityTable}(x, ..., reference = NULL, trend = FALSE)
 }
 \arguments{
 \item{x}{First life table to be plotted. Must be a \code{mortalityTable}
@@ -31,6 +31,9 @@ passed on to \code{\link{plotMortalityTables}} or
 \item{reference}{The reference table that determines the 100\% values.
 If not given, the absolute mortality values are
 compared and plotted on a log-linear scale.}
+
+\item{trend}{If set to \code{TRUE}, the function \code{\link{plotMortalityTrend}}
+is used to plot the trends of the given tables.}
 }
 \description{
 \code{plot.mortalityTable} displays multiple life tables (objects of child
diff --git a/man/plotMortalityTrend.Rd b/man/plotMortalityTrend.Rd
index fb4e8a0..7539faf 100644
--- a/man/plotMortalityTrend.Rd
+++ b/man/plotMortalityTrend.Rd
@@ -5,7 +5,7 @@
 \title{Plot the trends of multiple mortality tables (life tables) in one chart}
 \usage{
 plotMortalityTrend(data, ..., xlim = NULL, ylim = NULL, xlab = NULL,
-  ylab = NULL, title = "", legend.position = c(0.9, 0.1),
+  ylab = NULL, title = "", legend.position = c(0.9, 0.9),
   legend.key.width = unit(25, "mm"))
 }
 \arguments{
-- 
GitLab