geom_sii_risksurface: geom_sii_risksurface

Description Usage Arguments Value Examples

Description

returns a 'ggplot2' object, based on geom_polygon, with filled, concentric circle(part)s, defined by the values in a hierarchy of levels.

Usage

1
2
3
4
5
6
7
8
geom_sii_risksurface(data = NULL, mapping = NULL,
  stat = "sii_risksurface",
  structure = ggsolvencyii::sii_structure_sf16_eng, squared = FALSE,
  levelmax = 99, aggregatesuffix = "_other", plotdetails = NULL,
  rotationdegrees = NULL, rotationdescription = NULL,
  maxscrvalue = NULL, scalingx = 1, scalingy = 1,
  position = "identity", na.rm = FALSE, show.legend = NA,
  inherit.aes = TRUE, ...)

Arguments

data

the dataset in tidyverse format (column 'description' as a factor). see examples in sii_z_ex2_data or sii_z_ex3_data

mapping

required aes(thetics) : x (i.e. time, longitude), y (i.e SCR ratio, lattitude), id, description (), value

stat

default stat is statsii_risksurface, combinations with other stat's are not tested

structure

(dataframe: default = sii_structure_sf16_eng)
A representation of the buildup from individual risks to the SCR. columns are

  1. description (chr),

  2. level (chr),

  3. childlevel (chr)

. In the standard formula structure, SCR has level 1, with childlevel 2. This means it consists of all datalines with level == 2, ie. "BSCR", "operational" and "Adjustment-LACDT". lines in the dataset with a suffix "d" behind the levelnumber are diversification items. As of now these are not used in any calculation. the values in column "description" in the dataset need to match the description in this file. The package contains also a file sii_structure_sf16_nld with Dutch terms in description column.

squared

(optional, boolean, default = FALSE)
when set to TRUE plot returns a square representation. Compared with a circle representation of the same data the height and width of the square are smaller than the radius of the circle. Segments which fall in the corner parts of the square are smaller than equally sized part which fall in the vertical or horizontal parts of the square.

levelmax

(integer or dataframe, default = 99)
a positive integer or a dataframe with columns 'level' and 'levelmax'.
The maximum amount of items in a certain level to be plotted. The smallest items are combined to one item. In the case level consisting of 7 items has a levelmax of 5 this results in 4 separate items and one grouped item.
For a less detailed plot sii_levelmax_sf16_995 and sii_levelmax_sf16_993 are present in the package where the components of market, life, non-life, health are combined in 5 or 3 items.

aggregatesuffix

(string, default = "_other")
When a certain level contains more items than specified by levelmax the smallest items are combined. The description is of the name of the one higher level (lower number) with a suffix

plotdetails

(optional) a table with columns 'levelordescription' and 'surface', indicating which circle elements to plot. When no table is provided all segments are plotted. example 3 shows how to combine geom_sii_risksurface and geom_sii_riskoutline by using using table sii_z_ex3_plotdetails. geom_sii_riskoutline uses other columns in the same table

rotationdegrees

(optional, integer, -360 to 360, default = NULL)
when given, the fixed amount of degrees (positive is clockwise) of which each item is rotated (as in a compass, -90 is a quarter rotation anti-clockwise), additive to possible rotation to description

rotationdescription

(optional, string, default = NULL)
default the orientation of the lower level (higher number) circles is based on the structure. When this parameter is not NULL then the circles are rotated in such a way that the indicated item lies in the "north-east" part of the circle.

maxscrvalue

(optional, double, default = NULL)
the scale of the different plot elements is is by default measured to the largest level 1 element (i.e. SCR) in the dataset, this can be overridden by this parameter for example when combining several plots

scalingx

(optional, positive value ,default = 1)
for plots where units in x and y are different in magnitude distortion can occur. This parameter scales only in x-direction

scalingy

(optional, positive value ,default = 1)
for plots where units in x and y are different in magnitude distortion can occur. This parameter scales only in y-direction

position

standard ggplot function

na.rm

standard ggplot function

show.legend

standard ggplot function

inherit.aes

standard ggplot function

...

ellipsis, a standard R parameter

Value

a ggplot object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
## dataset human readable
library(ggsolvencyii)
library(ggplot2)
t <- tidyr::spread(data = sii_z_ex1_data, key = description, value = value)
t <- as.data.frame(t)
t <- t[order(t$id),]
t <- dplyr::select( t, id, time, comparewithid, ratio, SCR, dplyr::everything())
t[1:3 ,1:8]

ggplot() +
geom_sii_risksurface(
    data = sii_z_ex1_data[sii_z_ex1_data$id == 1, ],
mapping = aes(x = time,
                  y = ratio,
                  id = id,
                  value = value,
                  description = description,
                  color = description,
                  fill = description
                   ) ) +
theme_bw() +
scale_fill_manual(name = "Risks",values = sii_x_fillcolors_sf16_eng) +
scale_color_manual(name = "Risks",values = sii_x_edgecolors_sf16_eng)

ggplot() +
 geom_sii_risksurface(
   data = sii_z_ex2_data,
   mapping = aes(x = time, y = ratio, id = id, value = value,
                 description = description,
                 # color = description,
                 fill = description
                 ),
   color = "black",
   levelmax = sii_levelmax_sf16_993) +
theme_bw() +
scale_fill_manual(name = "Risks",values = sii_x_fillcolors_sf16_eng) # +
# scale_color_manual(name = "Risks",values = sii_x_edgecolors_sf16_eng)



ggplot() +
 geom_sii_risksurface(data = sii_z_ex1_data[sii_z_ex1_data$id == 1, ],
       mapping = ggplot2::aes(x = time,
                              y = ratio,
                              ## x and y could for example be
                              ## longitude and latitude
                              ## in combination with plotted map
                              value = value,
                              id = id,
                              description = description,
                              fill = description, ## optional
                              color = description  ## optional
                              ),
           ## all parameters are shown here,
           ## the values behind the outcommented are the default values
             ## how and what
               ## structure = sii_structure_sf16_eng,
               ## plotdetails = NULL,
             ## grouping
               # levelmax = 99,
               # aggregatesuffix = "other",
             ## scaling
               # maxscrvalue =  NULL,
               # scalingx = 1,
               # scalingy = 1,
             ## rotation and squared
               # rotationdegrees = NULL,
               # rotationdescription = NULL,
               # squared = FALSE,
             ## cosmetic
               lwd = 0.25,
               # alpha = 1
       ) +
 theme_bw() +
 scale_fill_manual(name = "risks", values = sii_z_ex1_fillcolors) +
 scale_color_manual(name = "risks", values = sii_z_ex1_edgecolors)

vanzanden/ggsolvencyii documentation built on May 31, 2019, 5:23 p.m.