@@ -9,6 +9,14 @@ knitr::opts_chunk$set(
9
9
)
10
10
```
11
11
12
+ ``` {css, echo=FALSE}
13
+ @import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;700&display=swap');
14
+
15
+ table {
16
+ font-family: 'Roboto Condensed', sans-serif;
17
+ }
18
+ ```
19
+
12
20
This article shows how to calculate the descriptive analysis of companies'
13
21
employees.
14
22
@@ -24,16 +32,17 @@ options(readr.show_col_types = FALSE)
24
32
### Example product-level output of transition risk profile.
25
33
26
34
``` {r, echo=FALSE}
35
+ # read_csv("transition_risk_profile_at_product_level_all_countries_wide_22_08_24.csv")
27
36
transition_risk_product_example <- product_transition_risk |>
28
37
select(any_of(c("companies_id", "min_headcount", "max_headcount", "tilt_sector", "country"))) |>
29
38
distinct() |>
30
- mutate(companies_id = ifelse(companies_id == "insecticidal_clownanemonefish",
39
+ mutate(companies_id = ifelse(companies_id == "insecticidal_clownanemonefish",
31
40
"heliophobic_clownanemonefish", companies_id)) |>
32
- mutate(min_headcount = ifelse(companies_id %in% c("ironhearted_tarpan", "heliophobic_clownanemonefish"),
41
+ mutate(min_headcount = ifelse(companies_id %in% c("ironhearted_tarpan", "heliophobic_clownanemonefish"),
33
42
50, min_headcount)) |>
34
- mutate(max_headcount = ifelse(companies_id %in% c("ironhearted_tarpan", "heliophobic_clownanemonefish"),
43
+ mutate(max_headcount = ifelse(companies_id %in% c("ironhearted_tarpan", "heliophobic_clownanemonefish"),
35
44
100, max_headcount)) |>
36
- filter(companies_id %in% c("antimonarchy_canine", "nonphilosophical_llama",
45
+ filter(companies_id %in% c("antimonarchy_canine", "nonphilosophical_llama",
37
46
"subdermal_chipmunk", "fascist_maiasaura",
38
47
"ironhearted_tarpan", "heliophobic_clownanemonefish",
39
48
"subzero_whiteeye"))
@@ -49,68 +58,86 @@ kable(transition_risk_product_example |> head(20))
49
58
companies_headcount_range <- transition_risk_product_example |>
50
59
select(all_of(c("companies_id", "min_headcount", "max_headcount"))) |>
51
60
distinct() |>
52
- mutate(number_of_companies = n_distinct(companies_id), .by = c("min_headcount", "max_headcount")) |>
61
+ mutate("# of firms" = n_distinct(companies_id), .by = c("min_headcount", "max_headcount")) |>
53
62
select(-all_of(c("companies_id"))) |>
54
63
distinct() |>
55
64
arrange(min_headcount, max_headcount)
56
65
```
57
66
58
67
``` {r, echo=FALSE}
59
- kable(companies_headcount_range, align = "ccc ", caption = "Number of companies between range of min_headcount and max_headcount", escape = F) |>
60
- kable_classic(full_width = F, html_font = "Cambria ") |>
68
+ kable(companies_headcount_range, align = "llc ", caption = "# of firms between range of min_headcount and max_headcount", escape = F) |>
69
+ kable_classic(full_width = F, html_font = "Roboto Condensed ") |>
61
70
column_spec(1:3, width = "3cm")
62
71
```
63
72
64
73
### Bar plot
65
74
66
75
``` {r, warning=FALSE, echo=FALSE}
67
- companies_headcount_range$range_headcounts <- paste(companies_headcount_range$min_headcount, companies_headcount_range$max_headcount, sep = '-')
68
- ggplot(companies_headcount_range, aes(x = range_headcounts, y = number_of_companies, fill = range_headcounts)) +
76
+ companies_headcount_range_new <- mutate(companies_headcount_range, range_headcounts = paste(min_headcount, max_headcount, sep = '-')) |>
77
+ filter(!is.na(min_headcount)) |>
78
+ rename("number_of_companies" = "# of firms")
79
+ companies_headcount_range_new$range_headcounts <- factor(companies_headcount_range_new$range_headcounts,
80
+ levels = unique(companies_headcount_range_new$range_headcounts))
81
+ ggplot(companies_headcount_range_new, aes(x = range_headcounts, y = number_of_companies, fill = range_headcounts)) +
69
82
geom_bar(stat = "identity") +
70
- labs(title = "Number of companies between range of `min_headcount` and `max_headcount`")
83
+ labs(x = "Headcount Range", y = "Number of firms", title = "Number of companies between range of `min_headcount` and `max_headcount`",
84
+ fill = "Headcount Range")
71
85
```
72
86
73
87
### Number of companies between range of ` min_headcount ` and ` max_headcount ` grouped by ` tilt_sector `
74
88
75
89
``` {r, echo=FALSE}
76
90
companies_headcount_range_tilt_sector <- transition_risk_product_example |>
77
- select(all_of(c("companies_id", "min_headcount ", "max_headcount ", "tilt_sector "))) |>
91
+ select(all_of(c("companies_id", "tilt_sector ", "min_headcount ", "max_headcount "))) |>
78
92
distinct() |>
79
- mutate(number_of_companies = n_distinct(companies_id), .by = c("min_headcount ", "max_headcount ", "tilt_sector ")) |>
93
+ mutate("# of firms" = n_distinct(companies_id), .by = c("tilt_sector ", "min_headcount ", "max_headcount ")) |>
80
94
select(-all_of(c("companies_id"))) |>
81
95
distinct() |>
82
- arrange(min_headcount, max_headcount, tilt_sector)
96
+ filter(tilt_sector %in% c("construction", "industry", "land use")) |>
97
+ arrange(tilt_sector, min_headcount, max_headcount)
83
98
```
84
99
85
100
``` {r, echo=FALSE}
86
- kable(companies_headcount_range_tilt_sector, align = "cccc", caption = "Number of companies between range of min_headcount and max_headcount grouped by tilt_sector", escape = F) |>
87
- kable_classic(full_width = F, html_font = "Cambria") |>
88
- column_spec(1:4, width = "3cm")
101
+ kable(companies_headcount_range_tilt_sector, align = "lllc", caption = "# of firms between range of min_headcount and max_headcount grouped by tilt_sector", escape = F) |>
102
+ kable_classic(full_width = F, html_font = "Roboto Condensed") |>
103
+ column_spec(1:4, width = "3cm") |>
104
+ collapse_rows(columns = 1, valign = "top")
89
105
```
90
106
91
107
### Bar plot
92
108
93
109
``` {r, warning=FALSE, echo=FALSE}
94
- companies_headcount_range_tilt_sector$range_headcounts <- paste(companies_headcount_range_tilt_sector$min_headcount, companies_headcount_range_tilt_sector$max_headcount, companies_headcount_range_tilt_sector$tilt_sector, sep = '-')
95
- ggplot(companies_headcount_range_tilt_sector, aes(x = range_headcounts, y = number_of_companies, fill = range_headcounts)) +
110
+ companies_headcount_range_tilt_sector_new <- mutate(companies_headcount_range_tilt_sector, range_headcounts = paste(min_headcount, max_headcount, tilt_sector, sep = '-')) |>
111
+ filter(!is.na(min_headcount)) |>
112
+ rename("number_of_companies" = "# of firms") |>
113
+ arrange(min_headcount, tilt_sector)
114
+
115
+ companies_headcount_range_tilt_sector_new$range_headcounts <- factor(companies_headcount_range_tilt_sector_new$range_headcounts,
116
+ levels = companies_headcount_range_tilt_sector_new$range_headcounts)
117
+
118
+ ggplot(companies_headcount_range_tilt_sector_new, aes(x = range_headcounts, y = number_of_companies, fill = range_headcounts)) +
96
119
geom_bar(stat = "identity") +
97
- labs(title = "Number of companies between range of `min_headcount` and `max_headcount` \n grouped by `tilt_sector`")
120
+ labs(x = "Headcount Range", y = "Number of firms", title = "Number of companies between range of \n `min_headcount` and `max_headcount` \n grouped by `tilt_sector`", fill = "Headcount Range") +
121
+ theme_minimal() +
122
+ theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1))
98
123
```
99
124
100
125
### Number of companies between range of ` min_headcount ` and ` max_headcount ` grouped by ` tilt_sector ` and ` country `
101
126
102
127
``` {r, echo=FALSE}
103
128
companies_headcount_range_tilt_sector_country <- transition_risk_product_example |>
104
- select(all_of(c("companies_id", "min_headcount ", "max_headcount ", "tilt_sector ", "country"))) |>
129
+ select(all_of(c("companies_id", "tilt_sector ", "min_headcount ", "max_headcount ", "country"))) |>
105
130
distinct() |>
106
- mutate(number_of_companies = n_distinct(companies_id), .by = c("min_headcount ", "max_headcount ", "tilt_sector ", "country")) |>
131
+ mutate("# of firms" = n_distinct(companies_id), .by = c("tilt_sector ", "min_headcount ", "max_headcount ", "country")) |>
107
132
select(-all_of(c("companies_id"))) |>
108
133
distinct() |>
109
- arrange(min_headcount, max_headcount, tilt_sector, country)
134
+ filter(tilt_sector %in% c("construction", "industry", "land use")) |>
135
+ arrange(tilt_sector, min_headcount, max_headcount, country)
110
136
```
111
137
112
138
``` {r, echo=FALSE}
113
- kable(companies_headcount_range_tilt_sector_country, align = "ccccc", caption = "Number of companies between range of min_headcount and max_headcount grouped by tilt_sector and country", escape = F) |>
114
- kable_classic(full_width = F, html_font = "Cambria") |>
115
- column_spec(1:5, width = "3cm")
139
+ kable(companies_headcount_range_tilt_sector_country, align = "llllc", caption = "# of firms between range of min_headcount and max_headcount grouped by tilt_sector and country", escape = F) |>
140
+ kable_classic(full_width = F, html_font = "Roboto Condensed") |>
141
+ column_spec(1:5, width = "3cm") |>
142
+ collapse_rows(columns = 1, valign = "top")
116
143
```
0 commit comments