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

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.
parent 06007cae
No related branches found
No related tags found
No related merge requests found
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#' @param reference The reference table that determines the 100\% values. #' @param reference The reference table that determines the 100\% values.
#' If not given, the absolute mortality values are #' If not given, the absolute mortality values are
#' compared and plotted on a log-linear scale. #' 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 #' @examples
#' # Load the Austrian census data #' # Load the Austrian census data
...@@ -55,9 +58,11 @@ ...@@ -55,9 +58,11 @@
#' #'
#' @import scales #' @import scales
#' @export #' @export
plot.mortalityTable = function(x, ..., reference=NULL) { plot.mortalityTable = function(x, ..., reference = NULL, trend = FALSE) {
if (!missing(reference) && !is.null(reference)) { if (!missing(trend) && isTRUE(trend)) {
plotMortalityTableComparisons(x, ..., reference=reference) plotMortalityTrend(x, ..., reference = reference)
} else if (!missing(reference) && !is.null(reference)) {
plotMortalityTableComparisons(x, ..., reference = reference)
} else { } else {
plotMortalityTables(x, ...) plotMortalityTables(x, ...)
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
\alias{plot.mortalityTable} \alias{plot.mortalityTable}
\title{Plot multiple mortality tables (life tables) in one plot} \title{Plot multiple mortality tables (life tables) in one plot}
\usage{ \usage{
\method{plot}{mortalityTable}(x, ..., reference = NULL) \method{plot}{mortalityTable}(x, ..., reference = NULL, trend = FALSE)
} }
\arguments{ \arguments{
\item{x}{First life table to be plotted. Must be a \code{mortalityTable} \item{x}{First life table to be plotted. Must be a \code{mortalityTable}
...@@ -31,6 +31,9 @@ passed on to \code{\link{plotMortalityTables}} or ...@@ -31,6 +31,9 @@ passed on to \code{\link{plotMortalityTables}} or
\item{reference}{The reference table that determines the 100\% values. \item{reference}{The reference table that determines the 100\% values.
If not given, the absolute mortality values are If not given, the absolute mortality values are
compared and plotted on a log-linear scale.} 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{ \description{
\code{plot.mortalityTable} displays multiple life tables (objects of child \code{plot.mortalityTable} displays multiple life tables (objects of child
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
\title{Plot the trends of multiple mortality tables (life tables) in one chart} \title{Plot the trends of multiple mortality tables (life tables) in one chart}
\usage{ \usage{
plotMortalityTrend(data, ..., xlim = NULL, ylim = NULL, xlab = NULL, 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")) legend.key.width = unit(25, "mm"))
} }
\arguments{ \arguments{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment