|
| 1 | +--- |
| 2 | +title: "Descriptive analysis of employees" |
| 3 | +--- |
| 4 | + |
| 5 | +```{r, include = FALSE} |
| 6 | +knitr::opts_chunk$set( |
| 7 | + collapse = TRUE, |
| 8 | + comment = "#>" |
| 9 | +) |
| 10 | +``` |
| 11 | + |
| 12 | +This article shows how to calculate the descriptive analysis of companies' |
| 13 | +employees. |
| 14 | + |
| 15 | +```{r setup, warning=FALSE} |
| 16 | +library(tiltDataAnalysis) |
| 17 | +library(dplyr) |
| 18 | +library(knitr) |
| 19 | +library(ggplot2) |
| 20 | +options(readr.show_col_types = FALSE) |
| 21 | +``` |
| 22 | + |
| 23 | +### Example product-level output of transition risk profile. |
| 24 | + |
| 25 | +```{r} |
| 26 | +transition_risk_product_example <- product_transition_risk |> |
| 27 | + select(any_of(c("companies_id", "min_headcount", "max_headcount", "tilt_sector", "country"))) |> |
| 28 | + distinct() |> |
| 29 | + mutate(companies_id = ifelse(companies_id == "insecticidal_clownanemonefish", |
| 30 | + "heliophobic_clownanemonefish", companies_id)) |> |
| 31 | + mutate(min_headcount = ifelse(companies_id %in% c("ironhearted_tarpan", "heliophobic_clownanemonefish"), |
| 32 | + 50, min_headcount)) |> |
| 33 | + mutate(max_headcount = ifelse(companies_id %in% c("ironhearted_tarpan", "heliophobic_clownanemonefish"), |
| 34 | + 100, max_headcount)) |> |
| 35 | + filter(companies_id %in% c("antimonarchy_canine", "nonphilosophical_llama", |
| 36 | + "subdermal_chipmunk", "fascist_maiasaura", |
| 37 | + "ironhearted_tarpan", "heliophobic_clownanemonefish", |
| 38 | + "subzero_whiteeye")) |
| 39 | +
|
| 40 | +kable(transition_risk_product_example) |
| 41 | +``` |
| 42 | + |
| 43 | +### Number of companies between `min_headcount` and `max_headcount` range |
| 44 | + |
| 45 | +```{r} |
| 46 | +companies_headcount_range <- transition_risk_product_example |> |
| 47 | + select(all_of(c("companies_id", "min_headcount", "max_headcount"))) |> |
| 48 | + distinct() |> |
| 49 | + mutate(n_comp_headcount_range = n_distinct(companies_id), .by = c("min_headcount", "max_headcount")) |> |
| 50 | + select(-all_of(c("companies_id"))) |> |
| 51 | + distinct() |> |
| 52 | + arrange(min_headcount, max_headcount) |
| 53 | + |
| 54 | +kable(companies_headcount_range) |
| 55 | +``` |
| 56 | + |
| 57 | +### Bar plot |
| 58 | + |
| 59 | +```{r, warning=FALSE} |
| 60 | +companies_headcount_range$range_headcounts <- paste(companies_headcount_range$min_headcount, companies_headcount_range$max_headcount, sep = '-') |
| 61 | +ggplot(companies_headcount_range, aes(x = range_headcounts, y = n_comp_headcount_range, fill = range_headcounts)) + |
| 62 | + geom_bar(stat = "identity") |
| 63 | +``` |
| 64 | + |
| 65 | +### Number of companies between `min_headcount` and `max_headcount` range grouped by `tilt_sector` |
| 66 | + |
| 67 | +```{r} |
| 68 | +companies_headcount_range_tilt_sector <- transition_risk_product_example |> |
| 69 | + select(all_of(c("companies_id", "min_headcount", "max_headcount", "tilt_sector"))) |> |
| 70 | + distinct() |> |
| 71 | + mutate(n_comp_headcount_range_tilt_sector = n_distinct(companies_id), .by = c("min_headcount", "max_headcount", "tilt_sector")) |> |
| 72 | + select(-all_of(c("companies_id"))) |> |
| 73 | + distinct() |> |
| 74 | + arrange(min_headcount, max_headcount, tilt_sector) |
| 75 | + |
| 76 | +kable(companies_headcount_range_tilt_sector) |
| 77 | +``` |
| 78 | + |
| 79 | +### Number of companies between `min_headcount` and `max_headcount` range grouped by `tilt_sector` and `country` |
| 80 | + |
| 81 | +```{r} |
| 82 | +companies_headcount_range_tilt_sector_country <- transition_risk_product_example |> |
| 83 | + select(all_of(c("companies_id", "min_headcount", "max_headcount", "tilt_sector", "country"))) |> |
| 84 | + distinct() |> |
| 85 | + mutate(n_comp_headcount_range_tilt_sector_country = n_distinct(companies_id), .by = c("min_headcount", "max_headcount", "tilt_sector", "country")) |> |
| 86 | + select(-all_of(c("companies_id"))) |> |
| 87 | + distinct() |> |
| 88 | + arrange(min_headcount, max_headcount, tilt_sector, country) |
| 89 | + |
| 90 | +kable(companies_headcount_range_tilt_sector_country) |
| 91 | +``` |
0 commit comments