5  slope

Implement slope charts to depict the rate of change between two points. This is particularly useful for illustrating trends and making comparisons between different periods.

5.1 Setup

library(tidyverse) 
library(CGPfunctions)

5.2 Data preparation

newcancer %>%
  filter()
      Year             Type Survival
1   5 Year         Prostate       99
2  10 Year         Prostate       95
3  15 Year         Prostate       87
4  20 Year         Prostate       81
5   5 Year          Thyroid       96
6  10 Year          Thyroid       96
7  15 Year          Thyroid       94
8  20 Year          Thyroid       95
9   5 Year           Testis       95
10 10 Year           Testis       94
11 15 Year           Testis       91
12 20 Year           Testis       88
13  5 Year        Melanomas       89
14 10 Year        Melanomas       87
15 15 Year        Melanomas       84
16 20 Year        Melanomas       83
17  5 Year           Breast       86
18 10 Year           Breast       78
19 15 Year           Breast       71
20 20 Year           Breast       75
21  5 Year        Hodgkin's       85
22 10 Year        Hodgkin's       80
23 15 Year        Hodgkin's       74
24 20 Year        Hodgkin's       67
25  5 Year           Uterus       84
26 10 Year           Uterus       83
27 15 Year           Uterus       81
28 20 Year           Uterus       79
29  5 Year          Urinary       82
30 10 Year          Urinary       76
31 15 Year          Urinary       70
32 20 Year          Urinary       68
33  5 Year           Cervix       71
34 10 Year           Cervix       64
35 15 Year           Cervix       63
36 20 Year           Cervix       60
37  5 Year           Larynx       69
38 10 Year           Larynx       57
39 15 Year           Larynx       46
40 20 Year           Larynx       38
41  5 Year           Rectum       63
42 10 Year           Rectum       55
43 15 Year           Rectum       52
44 20 Year           Rectum       49
45  5 Year           Kidney       62
46 10 Year           Kidney       54
47 15 Year           Kidney       50
48 20 Year           Kidney       47
49  5 Year            Colon       62
50 10 Year            Colon       55
51 15 Year            Colon       54
52 20 Year            Colon       52
53  5 Year    Non-Hodgkin's       58
54 10 Year    Non-Hodgkin's       46
55 15 Year    Non-Hodgkin's       38
56 20 Year    Non-Hodgkin's       34
57  5 Year             Oral       57
58 10 Year             Oral       46
59 15 Year             Oral       38
60 20 Year             Oral       33
61  5 Year            Ovary       55
62 10 Year            Ovary       49
63 15 Year            Ovary       50
64 20 Year            Ovary       50
65  5 Year         Leukemia       43
66 10 Year         Leukemia       32
67 15 Year         Leukemia       30
68 20 Year         Leukemia       26
69  5 Year            Brain       32
70 10 Year            Brain       29
71 15 Year            Brain       28
72 20 Year            Brain       26
73  5 Year Multiple myeloma       30
74 10 Year Multiple myeloma       13
75 15 Year Multiple myeloma        7
76 20 Year Multiple myeloma        5
77  5 Year          Stomach       24
78 10 Year          Stomach       19
79 15 Year          Stomach       19
80 20 Year          Stomach       15
81  5 Year             Lung       15
82 10 Year             Lung       11
83 15 Year             Lung        7
84 20 Year             Lung        6
85  5 Year        Esophagus       14
86 10 Year        Esophagus        8
87 15 Year        Esophagus        8
88 20 Year        Esophagus        5
89  5 Year            Liver        8
90 10 Year            Liver        6
91 15 Year            Liver        6
92 20 Year            Liver        8
93  5 Year         Pancreas        4
94 10 Year         Pancreas        3
95 15 Year         Pancreas        3
96 20 Year         Pancreas        3
df <- newcancer[1:32, ]

5.3 Data visualization

newggslopegraph(dataframe = df,
                Times = Year,
                Measurement = Survival,
                Grouping = Type,
                Title = "",
                SubTitle = "",
                LineColor =  c("firebrick", rep("gray",4), "firebrick", rep("gray",2)),
                Caption = NULL)