Skip to contents

Generic presentation helper. Methods return a gt table for objects where a formatted reporting table is more useful than another plot.

Create a formatted gt table from an object returned by assess_excess_threshold(). The original object remains a regular data.frame subclass; as_gt() is only used when a presentation table is needed for a report, tariff note or pricing review.

Usage

as_gt(x, ...)

# S3 method for class 'threshold_assessment'
as_gt(
  x,
  claims = TRUE,
  loss = FALSE,
  premium = TRUE,
  locale = "nl-NL",
  loss_decimals = 0,
  premium_decimals = 0,
  ratio_decimals = 1,
  color_last_column = TRUE,
  title = NULL,
  subtitle = NULL,
  ...
)

Arguments

x

An object returned by assess_excess_threshold().

...

Unused.

claims

Logical. If TRUE, include claim-count columns.

loss

Logical. If TRUE, include loss amount columns. The default is FALSE to keep the threshold comparison compact.

premium

Logical. If TRUE, include pure-premium and premium-reduction columns.

locale

Character. Locale used for number formatting, for example "nl-NL" or "en-US".

loss_decimals, premium_decimals, ratio_decimals

Non-negative whole numbers controlling displayed decimals for loss amounts, premium amounts and percentage ratios.

color_last_column

Logical. If TRUE, color the final displayed column from white to yellow so the highest values stand out in the presentation table.

title

Optional character. Table title. If NULL, no table title is added.

subtitle

Optional character. Table subtitle. If NULL, no table subtitle is added.

Value

A gt_tbl object for supported methods.

A gt_tbl object.

Author

Martin Haringa

Examples

portfolio <- data.frame(
  policy_id = 1:10,
  sector = rep(c("Industry", "Retail"), each = 5),
  claim_count = c(
    0, 1, 1, 1, 1,
    0, 1, 1, 1, 1
  ),
  claim_amount = c(
    0, 25000, 120000, 50000, 175000,
    0, 40000, 90000, 150000, 300000
  ),
  policy_years = rep(1, 10)
)

thresholds <- assess_excess_threshold(
  data = portfolio,
  claim_amount = "claim_amount",
  thresholds = c(25000, 50000, 100000, 150000),
  exposure = "policy_years",
  group = "sector",
  claim_count = "claim_count"
)

if (requireNamespace("gt", quietly = TRUE)) {
  as_gt(thresholds)
}
Threshold Policy Years
Claims
Risk premium
Count Above threshold Before After Reduction Reduction (%)
Industry 25.000 5 4 3 74.000 20.000 54.000 73,0%
50.000 5 4 2 74.000 35.000 39.000 52,7%
100.000 5 4 2 74.000 55.000 19.000 25,7%
150.000 5 4 1 74.000 69.000 5.000 6,8%
Retail 25.000 5 4 4 116.000 20.000 96.000 82,8%
50.000 5 4 3 116.000 38.000 78.000 67,2%
100.000 5 4 2 116.000 66.000 50.000 43,1%
150.000 5 4 1 116.000 86.000 30.000 25,9%