Installing package into 'C:/Users/owner/AppData/Local/R/win-library/4.3'
(as 'lib' is unspecified)
package 'tidyverse' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\owner\AppData\Local\Temp\RtmpovrtGe\downloaded_packages
install.packages("janitor")
Installing package into 'C:/Users/owner/AppData/Local/R/win-library/4.3'
(as 'lib' is unspecified)
package 'janitor' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\owner\AppData\Local\Temp\RtmpovrtGe\downloaded_packages
install.packages("countrycode")
Installing package into 'C:/Users/owner/AppData/Local/R/win-library/4.3'
(as 'lib' is unspecified)
package 'countrycode' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\owner\AppData\Local\Temp\RtmpovrtGe\downloaded_packages
install.packages("hrbrthemes")
Installing package into 'C:/Users/owner/AppData/Local/R/win-library/4.3'
(as 'lib' is unspecified)
package 'hrbrthemes' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\owner\AppData\Local\Temp\RtmpovrtGe\downloaded_packages
install.packages("viridis")
Installing package into 'C:/Users/owner/AppData/Local/R/win-library/4.3'
(as 'lib' is unspecified)
package 'viridis' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\owner\AppData\Local\Temp\RtmpovrtGe\downloaded_packages
install.packages("here")
Installing package into 'C:/Users/owner/AppData/Local/R/win-library/4.3'
(as 'lib' is unspecified)
package 'here' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\owner\AppData\Local\Temp\RtmpovrtGe\downloaded_packages
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(janitor)
Attaching package: 'janitor'
The following objects are masked from 'package:stats':
chisq.test, fisher.test
NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow
library(viridis)
Loading required package: viridisLite
library(readxl)library(here)
here() starts at C:/Users/owner/Desktop/Sustainable Finance/R/HW6
# A tibble: 93 × 23
...1 ...2 ...3 ...4 ...5 ...6 ...7 ...8 ...9 ...10 ...11
<chr> <dbl> <lgl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <lgl> <chr>
1 Mineral de… NA NA <NA> NA NA NA NA NA NA <NA>
2 <NA> NA NA <NA> NA NA NA NA NA NA <NA>
3 <NA> NA NA Stat… NA NA NA NA NA NA Anno…
4 <NA> 2022 NA 2025 2030 2035 2040 2045 2050 NA 2025
5 <NA> NA NA <NA> NA NA NA NA NA NA <NA>
6 Constraine… NA NA <NA> NA NA NA NA NA NA <NA>
7 Copper 381. NA 616.… 1389. 1736. 2233. 2418. 2313. NA 731.…
8 Cobalt 63.5 NA 61.2… 38.0 29.1 35.4 40.9 47.4 NA 71.1…
9 Graphite 557. NA 935.… 1590. 1782. 1691. 1492. 1077. NA 1100…
10 Lithium 69.6 NA 122.… 219. 307. 407. 450. 413. NA 144.…
# ℹ 83 more rows
# ℹ 12 more variables: ...12 <dbl>, ...13 <dbl>, ...14 <dbl>, ...15 <dbl>,
# ...16 <dbl>, ...17 <lgl>, ...18 <chr>, ...19 <dbl>, ...20 <dbl>,
# ...21 <dbl>, ...22 <dbl>, ...23 <dbl>
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`.
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
Rows: 1368 Columns: 5
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (3): EV_name, indicator, scenario
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.
[1] "Constrained nickel supply"
[2] "Wider use of silicon-rich anodes"
[3] "Faster uptake of solid state batteries"
[4] "Lower battery sizes"
[5] "Limited battery size reduction"
[6] "STEPS - Base case"
Visualization
#1
# 1cleaned_data |>filter(EV_name =="STEPS - Base case") |>filter(scenario =="Net Zero Emissions by 2050 scenario") |>filter(indicator !="Total EV") |>ggplot(aes(year, value, fill=indicator)) +geom_col(position ="stack") +# facet_wrap(~scenario)+labs(x="Year",y="Weight (kT)",title="Critical mineral demand increases dramatically",# subtitle="Net Zero Emissions by 2050 scenario",caption="Data: IEA") +theme_ft_rc()
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
#2
cleaned_data |># filter(EV_name == "STEPS - Base case") |> filter(scenario =="Net Zero Emissions by 2050 scenario") |>filter(indicator =="Total EV") |>ggplot(aes(x=year, y=value, color=EV_name)) +geom_line() +# facet_wrap(~EV_name)+labs(x="Year",y="Total Critical Minerals Weight (kT)",title="EV technology changes total critical mineral demand",subtitle="Under Net Zero Emissions by 2050 scenario",caption="Data: IEA") +theme_ft_rc()
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
[1] "Current Year" "Stated policies scenario"
[3] "Announced pledges scenario" "Net Zero Emissions by 2050 scenario"
update_geom_font_defaults(font_rc_light)cleaned_data |>filter(indicator=="Copper") |>filter(scenario !="Current Year") |>ggplot(aes(scenario, value)) +geom_col() +coord_flip() +labs(x="Copper demand", y="Scenarios",title="Net Zero scenario demands 3X stated policies copper demand for EV productino",# subtitle="A plot that is only useful for demonstration purposes, esp since you'd never\nreally want direct labels and axis labels",caption="Data: IEA") +theme_ipsum_rc(grid="X")
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
#4
cleaned_data |>filter(indicator %in%c("Nickel", "Copper", "Graphite")) |>filter(scenario %in%"Net Zero Emissions by 2050 scenario") |>ggplot() +aes(x = EV_name, fill = indicator, weight = value) +geom_bar() +scale_fill_hue(direction =1) +labs(x ="Conditions",y ="Demand (kT)",title ="Demand of top 3 critical minerals for EV production",fill ="Mineral type" ) +coord_flip() +theme_ipsum_rc() +facet_wrap(vars(year))
Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
font family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
family not found in Windows font database