plotMortalityTables: Plot multiple mortality tables (life tables) in one plot

Description Usage Arguments Examples

View source: R/plotMortalityTables.R

Description

plotMortalityTables prints multiple life tables (objects of child classes of mortalityTable) in one log-linear plot, with a legend showing the names of the tables.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
plotMortalityTables(
  data,
  ...,
  aes = NULL,
  ages = NULL,
  legend.title = "Sterbetafel",
  xlim = NULL,
  ylim = NULL,
  xlab = NULL,
  ylab = NULL,
  title = "",
  legend.position = c(0.9, 0.1),
  legend.justification = c(1, 0),
  legend.key.width = unit(25, "mm"),
  log = TRUE
)

Arguments

data

First life table to be plotted. Either a data.frame generated by makeQxDataFrame or a mortalityTable object

...

Additional life tables to be plotted (if data is a mortalityTable object)

aes

Optional aesthetics to append or override the default. The default aesthetics will always be applied first and provide defaults for x, y and color. This argument can be used to override the defaults or append other aesthetics.

ages

Plot only the given ages

legend.title

Title of the legend (NULL to hide)

xlim

X-axis limitatation (as a two-element vector)

ylim

Y-axis limitatation (as a two-element vector)

xlab

X-axis label (default: "Alter")

ylab

Y-axis label (default: "Sterbewahrscheinlichkeit q_x relativ zu ....")

title

The plot title

legend.position

The position of the legend (default is c(0.9,0.1))

legend.justification

The justification of the legend (default is c(1,))

legend.key.width

The keywith of the lines in the legend (default is unit(25,"mm"))

log

Display y axes in logarithmic scale (default: TRUE)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Load the Austrian census data
mortalityTables.load("Austria_Annuities")
mortalityTables.load("Austria_Census")

# Plot some select census tables in a log-linear plot (plot called
# with mortalityTable objects is equla to calling plotMortalitytTables directly)
plot(mort.AT.census.1869.male, mort.AT.census.1869.female,
     mort.AT.census.1971.male, mort.AT.census.1971.female,
     mort.AT.census.2011.male, mort.AT.census.2011.female,
     title="Austrian census tables",
     ylab=expression(q[x]), xlab="Age",
     xlim=c(0,90),
     legend.position=c(0.95,0.05))

# To compare period or cohort life tables, use the YOB and Period arguments:
plot(AVOe2005R.male, AVOe2005R.female, AVOe1996R.male, AVOe1996R.female,
    Period = 2018, title = "Austrian Annuity Tables, Period 2018")
plot(AVOe2005R.male, AVOe2005R.female, AVOe1996R.male, AVOe1996R.female,
    YOB = 2000, title = "Austrian Annuity Tables for cohort YOB=2000")

kainhofer/r-mortality-tables documentation built on Dec. 17, 2020, 3:53 a.m.