# 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# transpose the data from two rows into two columns using t()sheet_header_processed_EV <- sheet_header_EV |>t() |>as_tibble() |>rename(senario = V1, year = V2) |>fill(senario) |>replace_na(list(senario ="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_EV
# A tibble: 23 × 2
senario 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
read_iea_EV_table <-function(demand_name_range, demand_info_range) { demand_name <-read_minerals_demand_forEV_sheet(range = demand_name_range) |>pull() demand_info <-read_minerals_demand_forEV_sheet(range = demand_info_range) demand_mineral_info_col_names <-names(demand_info) demand_mineral_info_long <- demand_mineral_info |>rename(mineral =`...1`) |>pivot_longer(cols =-mineral,names_to ="demand_mineral_info_col_names") |>add_column(demand_name) combined_data_EV <- demand_mineral_info_long |>left_join(sheet_headers_and_col_names_EV, by =join_by(demand_mineral_info_col_names)) |># filter out what were empty columns (where years are NA)filter(!is.na(year)) |># case_when is supercharged if elsemutate(unit ="kiloton",# convert the year column from character to numericyear =as.integer(year) ) |>select(demand_name, mineral, senario, unit, year, value) combined_data_EV }
Rows: 1368 Columns: 6
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): demand_name, mineral, senario, unit
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.
trend_of_demand <-read.csv("/Users/xingyuning/Desktop/susfin/IEA/data/iea_EV_demand_for_critical_minerals.csv")copper_cobalt_demand_trend <-trend_of_demand |>filter(mineral %in%c("Copper","Cobalt"))ggplot(copper_cobalt_demand_trend, aes(x = year, y = value, color = mineral, linetype = senario)) +geom_line() +labs(title ="Demand Trend for Copper and Cobalt Over Time",x ="Year",y ="Demand (kiloton)",color ="Mineral",linetype ="Scenario") +theme_minimal()
Insight: This visualization can show the overall growth in demand for copper and cobalt. An upward trend would indicate increasing demand of copper in 2025-2040 under announced pledges scenario, net zero emissions by 2050 scenario and stated policies scenario. But the demand of cobalt would be basically on flat.
comparision_of_demand <-read.csv("/Users/xingyuning/Desktop/susfin/IEA/data/iea_EV_demand_for_critical_minerals.csv") comparision_of_demand_1 <- comparision_of_demand |>filter(year %in%c(2025, 2030, 2035, 2040)) |>filter(mineral !="Total EV")ggplot(comparision_of_demand_1, aes(x =factor(year), y = value, fill = senario)) +geom_bar(stat ="identity", position ="dodge") +facet_wrap(~mineral) +labs(title ="Demand Comparison Under Different Scenarios",x ="Year",y ="Demand (kiloton)",fill ="Scenario") +theme_minimal()+theme(axis.text.x =element_text(angle =90, vjust =0.5, hjust=1))+scale_y_continuous(limits =c(0, 6000))
Insight: Copper,Graphite,Nickel and Lithium would have increasing higher demand under theses three scenarios.
yearly_increase_in_demand <-read.csv("/Users/xingyuning/Desktop/susfin/IEA/data/iea_EV_demand_for_critical_minerals.csv") yearly_increase_in_demand_1 <- yearly_increase_in_demand |>group_by(mineral, senario) |>arrange(year) |>mutate(increase = value -lag(value)) |>filter(mineral !="Total EV")ggplot(yearly_increase_in_demand_1, aes(x = year, y = increase, color = senario)) +geom_line() +facet_wrap(~mineral) +labs(title ="Yearly Increase in Demand for Copper and Cobalt",x ="Year",y ="Increase in Demand (kiloton)",color ="Scenario") +theme_minimal() +theme(axis.text.x =element_text(angle =90, vjust =0.5, hjust=1))
`summarise()` has grouped output by 'year'. You can override using the
`.groups` argument.
ggplot(scenario_impact_1,aes(x = year, y = total_demand, fill = senario)) +geom_area(position ='stack') +labs(title ="Cumulative Scenario Impact on Mineral Demand",x ="Year",y ="Total Demand (kiloton)",fill ="Scenario") +theme_minimal()
Insight:
This visualization can illustrate the cumulative impact of different scenarios over time, providing a long-term view of demand changes. It could imply that emphasizing the importance of long-term planning in both policy formulation and supply chain management.