# A tibble: 2 × 23
...1 ...2 ...3 ...4 ...5 ...6 ...7 ...8 ...9 ...10 ...11 ...12 ...13
<lgl> <dbl> <lgl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <lgl> <chr> <dbl> <dbl>
1 NA NA NA State… NA NA NA NA NA NA Anno… NA NA
2 NA 2022 NA 2025 2030 2035 2040 2045 2050 NA 2025 2030 2035
# ℹ 10 more variables: ...14 <dbl>, ...15 <dbl>, ...16 <dbl>, ...17 <lgl>,
# ...18 <chr>, ...19 <dbl>, ...20 <dbl>, ...21 <dbl>, ...22 <dbl>,
# ...23 <dbl>
Tidying the headers
sheet_header_processed <- sheet_header |># transpose the datat() |># turn it back into a tibbleas_tibble() |># make them meaningfulrename(scenario = V1, year = V2) |># fill scenario downfill(scenario) |>#insert "Current" at topreplace_na(list(scenario ="Current Year"))
Warning: The `x` argument of `as_tibble.matrix()` must have unique column names if
`.name_repair` is omitted as of tibble 2.0.0.
ℹ Using compatibility `.name_repair`.
sheet_header_processed
# A tibble: 23 × 2
scenario year
<chr> <chr>
1 Current Year <NA>
2 Current Year 2022
3 Current Year <NA>
4 Stated policies scenario 2025
5 Stated policies scenario 2030
6 Stated policies scenario 2035
7 Stated policies scenario 2040
8 Stated policies scenario 2045
9 Stated policies scenario 2050
10 Stated policies scenario <NA>
# ℹ 13 more rows
combined_data <- case_info_long |>left_join(sheet_headers_and_col_names, by =join_by(case_info_col_names)) |># filter out what were empty columns (where years are NA) filter(!is.na(year)) |>mutate(# convert the year column from character to numericyear =as.integer(year) ) |>rename(mineral = indicator,tech_scenarios = case_name,policy_scenarios = scenario) |>select(mineral, tech_scenarios, policy_scenarios, year, value)combined_data
# A tibble: 1,368 × 5
mineral tech_scenarios policy_scenarios year value
<chr> <chr> <chr> <int> <dbl>
1 Copper STEPS - Base case Current Year 2022 373.
2 Copper STEPS - Base case Stated policies scenario 2025 580.
3 Copper STEPS - Base case Stated policies scenario 2030 1044.
4 Copper STEPS - Base case Stated policies scenario 2035 1219.
5 Copper STEPS - Base case Stated policies scenario 2040 1421.
6 Copper STEPS - Base case Stated policies scenario 2045 1458.
7 Copper STEPS - Base case Stated policies scenario 2050 1346.
8 Copper STEPS - Base case Announced pledges scenario 2025 689.
9 Copper STEPS - Base case Announced pledges scenario 2030 1592.
10 Copper STEPS - Base case Announced pledges scenario 2035 2570.
# ℹ 1,358 more rows
Rows: 1368 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): mineral, tech_scenarios, policy_scenarios
dbl (2): year, value
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
cleaned_ev
# A tibble: 1,368 × 5
mineral tech_scenarios policy_scenarios year value
<chr> <chr> <chr> <dbl> <dbl>
1 Copper STEPS - Base case Current Year 2022 373.
2 Copper STEPS - Base case Stated policies scenario 2025 580.
3 Copper STEPS - Base case Stated policies scenario 2030 1044.
4 Copper STEPS - Base case Stated policies scenario 2035 1219.
5 Copper STEPS - Base case Stated policies scenario 2040 1421.
6 Copper STEPS - Base case Stated policies scenario 2045 1458.
7 Copper STEPS - Base case Stated policies scenario 2050 1346.
8 Copper STEPS - Base case Announced pledges scenario 2025 689.
9 Copper STEPS - Base case Announced pledges scenario 2030 1592.
10 Copper STEPS - Base case Announced pledges scenario 2035 2570.
# ℹ 1,358 more rows
Problem 1.2 Result
Base Case: Demand for Copper and Cobalt (by policy scenarios)
base_copper_cobalt <- base_case_table |>filter(mineral %in%c("Copper", "Cobalt"),!year =="2022")ggplot(base_copper_cobalt, aes(x = year, y = value, fill = mineral)) +geom_bar(stat ="identity", position ="stack") +labs(title ="Base Case: Demand for Copper and Cobalt (by policy scenarios)",subtitle ="Net zero emissions by 2050 scenario requires the most copper and cobalt",x ="",y ="Demand for Minerals in Kiloton" ) +facet_wrap(~ policy_scenarios)
Stated Policies Scenario: Demand for Copper (by technological scenarios)
state_policy_copper <- cleaned_ev |>filter(policy_scenarios =="Stated policies scenario", mineral =="Copper",!year =="2022")ggplot(state_policy_copper, aes(x = year, y = value)) +geom_bar(stat ="identity") +labs(title ="Stated Policies Scenario: Demand for Copper (by technological scenarios)",subtitle ="Constrained nickel supply scenario requires the most copper",x ="",y ="Demand for Copper in Kiloton" ) +facet_wrap(~ tech_scenarios)
copper_cobalt_2022 <- cleaned_ev |>filter(mineral %in%c("Copper", "Cobalt"), year =="2022") ggplot(copper_cobalt_2022, aes(x = tech_scenarios, y = value, fill = mineral)) +geom_bar(stat ="identity", position ="stack") +labs(title ="2022: Demand for Copper and Cobalt",subtitle ="Demand for copper is a lot more larger than cobalt",x ="",y ="Demand for Minerals in Kiloton" ) +theme(axis.text.x =element_text(angle =45, hjust =1))
Base Case: Demand for Copper and Cobalt (stated policies scenarios)
base_copper_cobalt_stated_policies <- base_case_table |>filter(mineral %in%c("Copper", "Cobalt"),!year =="2022", policy_scenarios =="Stated policies scenario")ggplot(base_copper_cobalt_stated_policies, aes(x = year, y = value, color = mineral)) +geom_line() +labs(title ="Demand for Copper and Cobalt (stated policies scenarios)",subtitle ="Demand for copper increases then decreases, while demand for cobalt keeps increasing",x ="",y ="Demand for Minerals in Kiloton" )