Skip to content

Commit

Permalink
Group rows for tiltsector and tiltsubsector columns and change font t…
Browse files Browse the repository at this point in the history
…o `Roboto Condensed` (#35)

* Group rows for tiltsector and tiltsubsector columns

* Change font to Roboto Condensed
  • Loading branch information
kalashsinghal authored Aug 20, 2024
1 parent 8e4a398 commit 1bdc16f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export(example_transition_risk_product_sector_cov)
export(example_transition_risk_product_transition_risk_cov)
export(example_transition_risk_product_trs_des_analysis)
export(show_reduction_targets_for_tilt_subsectors_per_grouping_sector)
importFrom(dplyr,arrange)
importFrom(dplyr,distinct)
importFrom(dplyr,filter)
importFrom(dplyr,mutate)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @examples
#' library(dplyr)
#' sector_product_example <- product_sector |>
#' select(c("tilt_subsector", "scenario", "year", "reduction_targets")) |>
#' select(c("tilt_sector" ,"tilt_subsector", "scenario", "year", "reduction_targets")) |>
#' distinct()
#' sector_product_example
#'
Expand All @@ -20,7 +20,7 @@
#' )
show_reduction_targets_for_tilt_subsectors_per_grouping_sector <- function(sector_product) {
sector_product |>
select(all_of(c("tilt_subsector", "scenario", "year", "reduction_targets"))) |>
select(all_of(c("tilt_sector", "tilt_subsector", "scenario", "year", "reduction_targets"))) |>
distinct() |>
mutate(grouping_sector = paste(.data$scenario, .data$year, sep = "_")) |>
select(-c("scenario", "year")) |>
Expand All @@ -34,5 +34,6 @@ show_reduction_targets_for_tilt_subsectors_per_grouping_sector <- function(secto
IPR_2050 = "1.5C RPS_2050",
WEO_2030 = "NZ 2050_2030",
WEO_2050 = "NZ 2050_2050",
)
) |>
arrange(.data$tilt_sector, .data$tilt_subsector)
}
1 change: 1 addition & 0 deletions R/tiltDataAnalysis-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"_PACKAGE"

## usethis namespace: start
#' @importFrom dplyr arrange
#' @importFrom dplyr distinct
#' @importFrom dplyr filter
#' @importFrom dplyr mutate
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions vignettes/articles/descriptive-analysis-amount_of_companies.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ options(readr.show_col_types = FALSE)

```{r, echo=FALSE}
emission_product_example <- product_emission |>
select(all_of(c("companies_id", "country", "emission_profile", "tilt_sector",
select(all_of(c("companies_id", "country", "emission_profile", "tilt_sector",
"tilt_subsector", "main_activity"))) |>
distinct() |>
mutate(companies_id = ifelse(companies_id == "insecticidal_clownanemonefish",
mutate(companies_id = ifelse(companies_id == "insecticidal_clownanemonefish",
"heliophobic_clownanemonefish", companies_id)) |>
filter(companies_id %in% c("antimonarchy_canine", "nonphilosophical_llama",
filter(companies_id %in% c("antimonarchy_canine", "nonphilosophical_llama",
"subdermal_chipmunk", "fascist_maiasaura",
"ironhearted_tarpan", "heliophobic_clownanemonefish",
"subzero_whiteeye"))
Expand All @@ -47,9 +47,9 @@ sector_product_example <- product_sector |>
select(all_of(c("companies_id", "country", "sector_profile", "tilt_sector",
"tilt_subsector", "main_activity"))) |>
distinct() |>
mutate(companies_id = ifelse(companies_id == "insecticidal_clownanemonefish",
mutate(companies_id = ifelse(companies_id == "insecticidal_clownanemonefish",
"heliophobic_clownanemonefish", companies_id)) |>
filter(companies_id %in% c("antimonarchy_canine", "nonphilosophical_llama",
filter(companies_id %in% c("antimonarchy_canine", "nonphilosophical_llama",
"subdermal_chipmunk", "fascist_maiasaura",
"ironhearted_tarpan", "heliophobic_clownanemonefish",
"subzero_whiteeye"))
Expand All @@ -66,9 +66,9 @@ transition_risk_product_example <- product_transition_risk |>
select(all_of(c("companies_id", "country", "transition_risk_category", "tilt_sector",
"tilt_subsector", "main_activity"))) |>
distinct() |>
mutate(companies_id = ifelse(companies_id == "insecticidal_clownanemonefish",
mutate(companies_id = ifelse(companies_id == "insecticidal_clownanemonefish",
"heliophobic_clownanemonefish", companies_id)) |>
filter(companies_id %in% c("antimonarchy_canine", "nonphilosophical_llama",
filter(companies_id %in% c("antimonarchy_canine", "nonphilosophical_llama",
"subdermal_chipmunk", "fascist_maiasaura",
"ironhearted_tarpan", "heliophobic_clownanemonefish",
"subzero_whiteeye"))
Expand All @@ -88,7 +88,7 @@ cat("Number of companies for transition risk profile:", n_distinct(transition_ri

### Number of companies that have atleast one product with `emission_profile`, with `sector_profile`, and with `transition_risk_category`

```{r, echo=FALSE}
```{r}
companies_atleast_one_product_with_profile <- function(data, profile) {
result <- data |>
select(all_of(c("companies_id", profile))) |>
Expand All @@ -107,7 +107,7 @@ cat("Number of companies that have atleast one product with `transition_risk_cat

### Number of companies that have more than one tilt_sectors for emission, sector, and transition risk profile

```{r, echo=FALSE}
```{r}
companies_with_multiple_tilt_sectors <- function(data) {
result <- data |>
select(all_of(c("companies_id", "tilt_sector"))) |>
Expand All @@ -127,7 +127,7 @@ cat("Number of companies that have more than one tilt_sectors for transition ris

### Number of companies that have more than one tilt_subsectors for emission, sector, and transition risk profile

```{r, echo=FALSE}
```{r}
companies_with_multiple_tilt_subsectors <- function(data) {
result <- data |>
select(all_of(c("companies_id", "tilt_subsector"))) |>
Expand All @@ -147,7 +147,7 @@ cat("Number of companies that have more than one tilt_subsectors for transition

### Number of companies per tilt_sector for emission, sector, and transition risk profile

```{r, echo=FALSE}
```{r}
companies_per_single_benchmark <- function(data, benchmark) {
data |>
select(all_of(c("companies_id", benchmark))) |>
Expand Down Expand Up @@ -201,7 +201,7 @@ kable(companies_per_single_benchmark(transition_risk_product_example, "country")

### Number of companies per country and tilt_sector emission, sector, and transition risk profile

```{r, echo=FALSE}
```{r}
companies_per_double_benchmark <- function(data, benchmark_first, benchmark_second) {
data |>
select(all_of(c("companies_id", benchmark_first, benchmark_second))) |>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ knitr::opts_chunk$set(
)
```

```{css, echo=FALSE}
@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@400;700&display=swap');
table {
font-family: 'Roboto Condensed', sans-serif;
}
```

This article outlines how to show reduction targets for all `tilt_subsectors` per
grouping_sector using product-level output of Sector profile indicator.

Expand All @@ -24,7 +32,7 @@ options(readr.show_col_types = FALSE)

```{r}
sector_product_example <- product_sector |>
select(c("tilt_subsector", "scenario", "year", "reduction_targets")) |>
select(c("tilt_sector", "tilt_subsector", "scenario", "year", "reduction_targets")) |>
distinct()
kable(sector_product_example |> head(20))
Expand All @@ -37,8 +45,9 @@ result <- show_reduction_targets_for_tilt_subsectors_per_grouping_sector(
sector_product_example
)
kable(result, align = "lcccc", caption = "Reduction targets for all `tilt_subsectors` per grouping_sector", escape = F) |>
kable_classic(full_width = F, html_font = "Cambria") |>
column_spec(1, width = "6cm") |>
column_spec(2:5, width = "2.5cm")
kable(result, align = "llcccc", caption = "Reduction targets for all `tilt_subsectors` per grouping_sector", escape = F) |>
kable_classic(full_width = F, html_font = "Roboto Condensed") |>
column_spec(2, width = "6cm") |>
column_spec(3:6, width = "2.5cm") |>
collapse_rows(columns = 1, valign = "top")
```

0 comments on commit 1bdc16f

Please sign in to comment.