The US Geological Survey publishes a list of Strategic Minerals ( https://www.usgs.gov/news/national-news-release/us-geological-survey-releases-2022-list-critical-minerals ). Having a secure supply of these minerals is essential to our security and economic prosperity. However many of these minerals are sourced from outside of the US. This assignment is to develop a reference catalog of the source or sources of each of these minerals and a judgement on the reliability of each source under stressed circumstance (e.g. war, economic crisis, etc.) Notes:
You will need to identify a source or sources for each of the minerals in the 2022 List of Critical Minerals
You will need to categorize each source country as an ally, a competitor or a neutral party.
You will need to develop data visualizations that tell the story of source dependency and shortfall impact.
#Installing and loading the readxl package
library(readxl)
#Specifying the file path
file_path <- "C:/Users/aleja/Desktop/Total demand key minerals.xlsx"
#Reading the Excel file into a dataframe
minerals_data <- read_excel(file_path)## New names:
## • `` -> `...2`
## • `` -> `...3`
## • `` -> `...4`
## • `` -> `...5`
## • `` -> `...6`
## • `` -> `...7`
## • `` -> `...8`
## • `` -> `...9`
## • `` -> `...10`
## • `` -> `...11`
## • `` -> `...12`
## • `` -> `...13`
## • `` -> `...14`
## • `` -> `...15`
## • `` -> `...16`
## • `` -> `...17`
## • `` -> `...18`
## • `` -> `...19`
## • `` -> `...20`
## • `` -> `...21`
## • `` -> `...22`
## • `` -> `...23`
## tibble [58 × 23] (S3: tbl_df/tbl/data.frame)
## $ Total demand for lithium, copper, cobalt, nickel and neodymium (kt): chr [1:58] NA NA NA NA ...
## $ ...2 : num [1:58] NA NA 2022 NA NA ...
## $ ...3 : logi [1:58] NA NA NA NA NA NA ...
## $ ...4 : chr [1:58] NA "Stated policies scenario" "2025" NA ...
## $ ...5 : num [1:58] NA NA 2030 NA NA ...
## $ ...6 : num [1:58] NA NA 2035 NA NA ...
## $ ...7 : num [1:58] NA NA 2040 NA NA ...
## $ ...8 : num [1:58] NA NA 2045 NA NA ...
## $ ...9 : num [1:58] NA NA 2050 NA NA ...
## $ ...10 : logi [1:58] NA NA NA NA NA NA ...
## $ ...11 : chr [1:58] NA "Announced pledges scenario" "2025" NA ...
## $ ...12 : num [1:58] NA NA 2030 NA NA ...
## $ ...13 : num [1:58] NA NA 2035 NA NA ...
## $ ...14 : num [1:58] NA NA 2040 NA NA ...
## $ ...15 : num [1:58] NA NA 2045 NA NA ...
## $ ...16 : num [1:58] NA NA 2050 NA NA ...
## $ ...17 : logi [1:58] NA NA NA NA NA NA ...
## $ ...18 : chr [1:58] NA "Net Zero Emissions by 2050 scenario" "2025" NA ...
## $ ...19 : num [1:58] NA NA 2030 NA NA ...
## $ ...20 : num [1:58] NA NA 2035 NA NA ...
## $ ...21 : num [1:58] NA NA 2040 NA NA ...
## $ ...22 : num [1:58] NA NA 2045 NA NA ...
## $ ...23 : num [1:58] NA NA 2050 NA NA ...
## # A tibble: 6 × 23
## Total demand for lithi…¹ ...2 ...3 ...4 ...5 ...6 ...7 ...8 ...9 ...10
## <chr> <dbl> <lgl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <lgl>
## 1 <NA> NA NA <NA> NA NA NA NA NA NA
## 2 <NA> NA NA Stat… NA NA NA NA NA NA
## 3 <NA> 2022 NA 2025 2030 2035 2040 2045 2050 NA
## 4 <NA> NA NA <NA> NA NA NA NA NA NA
## 5 Copper NA NA <NA> NA NA NA NA NA NA
## 6 Solar PV 682. NA 778.… 907. 925. 959. 1122. 1262. NA
## # ℹ abbreviated name:
## # ¹​`Total demand for lithium, copper, cobalt, nickel and neodymium (kt)`
## # ℹ 13 more variables: ...11 <chr>, ...12 <dbl>, ...13 <dbl>, ...14 <dbl>,
## # ...15 <dbl>, ...16 <dbl>, ...17 <lgl>, ...18 <chr>, ...19 <dbl>,
## # ...20 <dbl>, ...21 <dbl>, ...22 <dbl>, ...23 <dbl>
#Creating dataframes for each mineral
copper_data <- data.frame(
Mineral = "Copper",
Category = c("Solar PV", "Wind", "Other low emissions power generation", "Electric vehicles", "Grid battery storage", "Electricity networks", "Hydrogen technologies", "Total clean technologies", "Other uses", "Total demand", "Share of clean technologies in total demand"),
Total_Demand = c(682, 394, 85, 373, 20, 4182, 0, 5736, NA, NA, 22)
)
cobalt_data <- data.frame(
Mineral = "Cobalt",
Category = c("Low emissions power generation", "Electric vehicles", "Grid battery storage", "Hydrogen technologies", "Total clean technologies", "Other uses", "Total demand", "Share of clean technologies in total demand"),
Total_Demand = c(0, 65, 4, 0, 68, 103, 171, 40)
)
lithium_data <- data.frame(
Mineral = "Lithium",
Category = c("Electric vehicles", "Grid battery storage", "Total clean technologies", "Other uses", "Total demand", "Share of clean technologies in total demand"),
Total_Demand = c(70, 3, 73, 57, 130, 56)
)
nickel_data <- data.frame(
Mineral = "Nickel",
Category = c("Solar PV", "Wind", "Other low emissions power generation", "Electric vehicles", "Grid battery storage", "Hydrogen technologies", "Total clean technologies", "Other uses", "Total demand", "Share of clean technologies in total demand"),
Total_Demand = c(0, 37, 83, 326, 9, 2, 457, 2477, 2934, 16)
)
neodymium_data <- data.frame(
Mineral = "Neodymium",
Category = c("Wind", "Electric vehicles", "Total clean technologies", "Other uses", "Total demand", "Share of clean technologies in total demand"),
Total_Demand = c(6, 4, 10, 40, 50, 20)
)
# Combine dataframes into a single dataframe
mineral_data <- rbind(copper_data, cobalt_data, lithium_data, nickel_data, neodymium_data)
# Print the dataframe
print(mineral_data)## Mineral Category Total_Demand
## 1 Copper Solar PV 682
## 2 Copper Wind 394
## 3 Copper Other low emissions power generation 85
## 4 Copper Electric vehicles 373
## 5 Copper Grid battery storage 20
## 6 Copper Electricity networks 4182
## 7 Copper Hydrogen technologies 0
## 8 Copper Total clean technologies 5736
## 9 Copper Other uses NA
## 10 Copper Total demand NA
## 11 Copper Share of clean technologies in total demand 22
## 12 Cobalt Low emissions power generation 0
## 13 Cobalt Electric vehicles 65
## 14 Cobalt Grid battery storage 4
## 15 Cobalt Hydrogen technologies 0
## 16 Cobalt Total clean technologies 68
## 17 Cobalt Other uses 103
## 18 Cobalt Total demand 171
## 19 Cobalt Share of clean technologies in total demand 40
## 20 Lithium Electric vehicles 70
## 21 Lithium Grid battery storage 3
## 22 Lithium Total clean technologies 73
## 23 Lithium Other uses 57
## 24 Lithium Total demand 130
## 25 Lithium Share of clean technologies in total demand 56
## 26 Nickel Solar PV 0
## 27 Nickel Wind 37
## 28 Nickel Other low emissions power generation 83
## 29 Nickel Electric vehicles 326
## 30 Nickel Grid battery storage 9
## 31 Nickel Hydrogen technologies 2
## 32 Nickel Total clean technologies 457
## 33 Nickel Other uses 2477
## 34 Nickel Total demand 2934
## 35 Nickel Share of clean technologies in total demand 16
## 36 Neodymium Wind 6
## 37 Neodymium Electric vehicles 4
## 38 Neodymium Total clean technologies 10
## 39 Neodymium Other uses 40
## 40 Neodymium Total demand 50
## 41 Neodymium Share of clean technologies in total demand 20
#Extracting the first two columns (Mineral and Category) from the combined dataframe
mineral_category <- mineral_data[, c("Mineral", "Category")]
#Printing the extracted dataframe
print(mineral_category)## Mineral Category
## 1 Copper Solar PV
## 2 Copper Wind
## 3 Copper Other low emissions power generation
## 4 Copper Electric vehicles
## 5 Copper Grid battery storage
## 6 Copper Electricity networks
## 7 Copper Hydrogen technologies
## 8 Copper Total clean technologies
## 9 Copper Other uses
## 10 Copper Total demand
## 11 Copper Share of clean technologies in total demand
## 12 Cobalt Low emissions power generation
## 13 Cobalt Electric vehicles
## 14 Cobalt Grid battery storage
## 15 Cobalt Hydrogen technologies
## 16 Cobalt Total clean technologies
## 17 Cobalt Other uses
## 18 Cobalt Total demand
## 19 Cobalt Share of clean technologies in total demand
## 20 Lithium Electric vehicles
## 21 Lithium Grid battery storage
## 22 Lithium Total clean technologies
## 23 Lithium Other uses
## 24 Lithium Total demand
## 25 Lithium Share of clean technologies in total demand
## 26 Nickel Solar PV
## 27 Nickel Wind
## 28 Nickel Other low emissions power generation
## 29 Nickel Electric vehicles
## 30 Nickel Grid battery storage
## 31 Nickel Hydrogen technologies
## 32 Nickel Total clean technologies
## 33 Nickel Other uses
## 34 Nickel Total demand
## 35 Nickel Share of clean technologies in total demand
## 36 Neodymium Wind
## 37 Neodymium Electric vehicles
## 38 Neodymium Total clean technologies
## 39 Neodymium Other uses
## 40 Neodymium Total demand
## 41 Neodymium Share of clean technologies in total demand
#Loading the required packages
library(kableExtra)
#Creating a table with the Mineral, Category, and Total Demand columns
table <- mineral_data[, c("Mineral", "Category", "Total_Demand")]
#Displaying the table with kable
kable(table, format = "html", caption = "Mineral Category Table") %>%
kable_styling(full_width = FALSE)| Mineral | Category | Total_Demand |
|---|---|---|
| Copper | Solar PV | 682 |
| Copper | Wind | 394 |
| Copper | Other low emissions power generation | 85 |
| Copper | Electric vehicles | 373 |
| Copper | Grid battery storage | 20 |
| Copper | Electricity networks | 4182 |
| Copper | Hydrogen technologies | 0 |
| Copper | Total clean technologies | 5736 |
| Copper | Other uses | NA |
| Copper | Total demand | NA |
| Copper | Share of clean technologies in total demand | 22 |
| Cobalt | Low emissions power generation | 0 |
| Cobalt | Electric vehicles | 65 |
| Cobalt | Grid battery storage | 4 |
| Cobalt | Hydrogen technologies | 0 |
| Cobalt | Total clean technologies | 68 |
| Cobalt | Other uses | 103 |
| Cobalt | Total demand | 171 |
| Cobalt | Share of clean technologies in total demand | 40 |
| Lithium | Electric vehicles | 70 |
| Lithium | Grid battery storage | 3 |
| Lithium | Total clean technologies | 73 |
| Lithium | Other uses | 57 |
| Lithium | Total demand | 130 |
| Lithium | Share of clean technologies in total demand | 56 |
| Nickel | Solar PV | 0 |
| Nickel | Wind | 37 |
| Nickel | Other low emissions power generation | 83 |
| Nickel | Electric vehicles | 326 |
| Nickel | Grid battery storage | 9 |
| Nickel | Hydrogen technologies | 2 |
| Nickel | Total clean technologies | 457 |
| Nickel | Other uses | 2477 |
| Nickel | Total demand | 2934 |
| Nickel | Share of clean technologies in total demand | 16 |
| Neodymium | Wind | 6 |
| Neodymium | Electric vehicles | 4 |
| Neodymium | Total clean technologies | 10 |
| Neodymium | Other uses | 40 |
| Neodymium | Total demand | 50 |
| Neodymium | Share of clean technologies in total demand | 20 |
#Loading the required packages
library(kableExtra)
#Removing rows with NA values
mineral_data_clean <- mineral_data[complete.cases(mineral_data), ]
#Creating a table with the Mineral, Category, and Total Demand columns
table <- mineral_data_clean[, c("Mineral", "Category", "Total_Demand")]
#Displaying the table with kable
kable(table, format = "html", caption = "Mineral Category Table") %>%
kable_styling(full_width = FALSE)| Mineral | Category | Total_Demand | |
|---|---|---|---|
| 1 | Copper | Solar PV | 682 |
| 2 | Copper | Wind | 394 |
| 3 | Copper | Other low emissions power generation | 85 |
| 4 | Copper | Electric vehicles | 373 |
| 5 | Copper | Grid battery storage | 20 |
| 6 | Copper | Electricity networks | 4182 |
| 7 | Copper | Hydrogen technologies | 0 |
| 8 | Copper | Total clean technologies | 5736 |
| 11 | Copper | Share of clean technologies in total demand | 22 |
| 12 | Cobalt | Low emissions power generation | 0 |
| 13 | Cobalt | Electric vehicles | 65 |
| 14 | Cobalt | Grid battery storage | 4 |
| 15 | Cobalt | Hydrogen technologies | 0 |
| 16 | Cobalt | Total clean technologies | 68 |
| 17 | Cobalt | Other uses | 103 |
| 18 | Cobalt | Total demand | 171 |
| 19 | Cobalt | Share of clean technologies in total demand | 40 |
| 20 | Lithium | Electric vehicles | 70 |
| 21 | Lithium | Grid battery storage | 3 |
| 22 | Lithium | Total clean technologies | 73 |
| 23 | Lithium | Other uses | 57 |
| 24 | Lithium | Total demand | 130 |
| 25 | Lithium | Share of clean technologies in total demand | 56 |
| 26 | Nickel | Solar PV | 0 |
| 27 | Nickel | Wind | 37 |
| 28 | Nickel | Other low emissions power generation | 83 |
| 29 | Nickel | Electric vehicles | 326 |
| 30 | Nickel | Grid battery storage | 9 |
| 31 | Nickel | Hydrogen technologies | 2 |
| 32 | Nickel | Total clean technologies | 457 |
| 33 | Nickel | Other uses | 2477 |
| 34 | Nickel | Total demand | 2934 |
| 35 | Nickel | Share of clean technologies in total demand | 16 |
| 36 | Neodymium | Wind | 6 |
| 37 | Neodymium | Electric vehicles | 4 |
| 38 | Neodymium | Total clean technologies | 10 |
| 39 | Neodymium | Other uses | 40 |
| 40 | Neodymium | Total demand | 50 |
| 41 | Neodymium | Share of clean technologies in total demand | 20 |
library(ggplot2)
#Aggregate total demand for each mineral
total_demand <- aggregate(Total_Demand ~ Mineral, data = mineral_data_clean, sum)
#Creating a bar chart
ggplot(total_demand, aes(x = Mineral, y = Total_Demand, fill = Mineral)) +
geom_bar(stat = "identity") +
labs(title = "Total Demand of Each Mineral 2022",
x = "Mineral",
y = "Total Demand") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))Usage in Clean Technologies: The data highlights the significant demand for minerals like copper, cobalt, lithium, nickel, and neodymium in clean technologies such as solar PV, wind power, electric vehicles, and grid battery storage. This indicates the importance of these minerals in supporting the transition towards renewable energy and low-emission technologies.
Diverse Applications: Each mineral serves multiple applications beyond clean technologies. For example, copper is also used in electricity networks, while nickel finds applications in other low emissions power generation methods. Understanding the diverse applications of these minerals helps assess their overall importance in various industries.
Strategic Importance of Clean Technologies: The share of clean technologies in total demand for each mineral provides insights into the strategic importance of these minerals in driving the clean energy transition. Minerals like cobalt and lithium, which have a higher share of demand from clean technologies, are crucial for accelerating the adoption of electric vehicles and energy storage solutions.
Supply Chain Risks: The concentration of demand for certain minerals in specific applications, such as electric vehicles and grid battery storage, highlights potential supply chain risks. Dependency on a limited number of applications or industries can make the supply chain vulnerable to disruptions, emphasizing the need for diversification and resilience strategies.
Policy Implications: Policymakers can use this data to formulate policies that promote sustainable sourcing, recycling, and domestic production of these critical minerals. Ensuring a stable and diversified supply of these minerals is essential for achieving long-term energy security and environmental sustainability goals.
#Loading the dataset
wits_partner <- read.csv("C:/Users/aleja/Desktop/WITS-Partner.csv", stringsAsFactors = FALSE)
#Displaying the structure of the dataset
str(wits_partner)## 'data.frame': 126 obs. of 31 variables:
## $ Reporter.Name : chr "United States" "United States" "United States" "United States" ...
## $ Partner.Name : chr "Albania" "United Arab Emirates" "Argentina" "Armenia" ...
## $ Year : int 2021 2021 2021 2021 2021 2021 2021 2021 2021 2021 ...
## $ Trade.Flow : chr "Import" "Import" "Import" "Import" ...
## $ Product.Group : chr "Minerals" "Minerals" "Minerals" "Minerals" ...
## $ Import..US..Thousand. : num 6 103303 3429 50 256116 ...
## $ Import.Product.Share.... : num 0.01 1.66 0.06 0.06 2.16 0.03 0 6.35 0.11 0.01 ...
## $ AHS.Simple.Average.... : num 0 0.14 0 NA 0 0.07 0 0 0.34 1.13 ...
## $ AHS.Weighted.Average.... : num 0 0 0 NA 0 0.3 0 0 0.04 1.65 ...
## $ AHS.Total.Tariff.Lines : int 2 12 9 NA 30 18 1 2 37 8 ...
## $ AHS.Dutiable.Tariff.Lines.Share.... : num 0 8.33 0 NA 0 ...
## $ AHS.Duty.Free.Tariff.Lines.Share.... : num 100 91.7 100 NA 100 ...
## $ AHS.Specific.Tariff.Lines.Share.... : num 0 0 0 NA 0 0 0 0 2.7 0 ...
## $ AHS.AVE.Tariff.Lines.Share.... : num 0 0 0 NA 0 0 0 0 0 0 ...
## $ AHS.MaxRate.... : num 0 2.9 0 NA 0 2.9 0 0 3 3 ...
## $ AHS.MinRate.... : int 0 0 0 NA 0 0 0 0 0 0 ...
## $ AHS.SpecificDuty.Imports..US..Thousand.: num 0 0 0 NA 0 ...
## $ AHS.Dutiable.Imports..US..Thousand. : num 0 25.7 0 NA 0 ...
## $ AHS.Duty.Free.Imports..US..Thousand. : num 6 9330 3332 NA 235201 ...
## $ MFN.Simple.Average.... : num 1.5 0.14 0.14 NA 0.23 0.07 0 1.28 0.34 1.13 ...
## $ MFN.Weighted.Average.... : num 1.5 0 0.04 NA 0.06 0.3 0 1.28 0.04 1.65 ...
## $ MFN.Total.Tariff.Lines : int 2 12 9 NA 30 18 1 2 37 8 ...
## $ MFN.Dutiable.Tariff.Lines.Share.... : num 50 8.33 11.11 NA 6.67 ...
## $ MFN.Duty.Free.Tariff.Lines.Share.... : num 50 91.7 88.9 NA 90 ...
## $ MFN.Specific.Tariff.Lines.Share.... : num 0 0 0 NA 0 0 0 0 2.7 0 ...
## $ MFN.AVE.Tariff.Lines.Share.... : num 0 0 0 NA 3.33 0 0 50 0 0 ...
## $ MFN.MaxRate.... : num 3 2.9 2.9 NA 3 2.9 0 2.55 3 3 ...
## $ MFN.MinRate.... : int 0 0 0 NA 0 0 0 0 0 0 ...
## $ MFN.SpecificDuty.Imports..US..Thousand.: num 0 0 0 NA 0 ...
## $ MFN.Dutiable.Imports..US..Thousand. : num 6 25.7 149.1 NA 13465.2 ...
## $ MFN.Duty.Free.Imports..US..Thousand. : num 0 9330 3183 NA 221735 ...
## Reporter.Name Partner.Name Year Trade.Flow Product.Group
## 1 United States Albania 2021 Import Minerals
## 2 United States United Arab Emirates 2021 Import Minerals
## 3 United States Argentina 2021 Import Minerals
## 4 United States Armenia 2021 Import Minerals
## 5 United States Australia 2021 Import Minerals
## 6 United States Austria 2021 Import Minerals
## Import..US..Thousand. Import.Product.Share.... AHS.Simple.Average....
## 1 6.00 0.01 0.00
## 2 103302.98 1.66 0.14
## 3 3428.89 0.06 0.00
## 4 49.98 0.06 NA
## 5 256115.59 2.16 0.00
## 6 4209.11 0.03 0.07
## AHS.Weighted.Average.... AHS.Total.Tariff.Lines
## 1 0.0 2
## 2 0.0 12
## 3 0.0 9
## 4 NA NA
## 5 0.0 30
## 6 0.3 18
## AHS.Dutiable.Tariff.Lines.Share.... AHS.Duty.Free.Tariff.Lines.Share....
## 1 0.00 100.00
## 2 8.33 91.67
## 3 0.00 100.00
## 4 NA NA
## 5 0.00 100.00
## 6 5.56 94.44
## AHS.Specific.Tariff.Lines.Share.... AHS.AVE.Tariff.Lines.Share....
## 1 0 0
## 2 0 0
## 3 0 0
## 4 NA NA
## 5 0 0
## 6 0 0
## AHS.MaxRate.... AHS.MinRate.... AHS.SpecificDuty.Imports..US..Thousand.
## 1 0.0 0 0
## 2 2.9 0 0
## 3 0.0 0 0
## 4 NA NA NA
## 5 0.0 0 0
## 6 2.9 0 0
## AHS.Dutiable.Imports..US..Thousand. AHS.Duty.Free.Imports..US..Thousand.
## 1 0.00 6.00
## 2 25.74 9329.78
## 3 0.00 3332.13
## 4 NA NA
## 5 0.00 235200.66
## 6 1171.06 2600.56
## MFN.Simple.Average.... MFN.Weighted.Average.... MFN.Total.Tariff.Lines
## 1 1.50 1.50 2
## 2 0.14 0.00 12
## 3 0.14 0.04 9
## 4 NA NA NA
## 5 0.23 0.06 30
## 6 0.07 0.30 18
## MFN.Dutiable.Tariff.Lines.Share.... MFN.Duty.Free.Tariff.Lines.Share....
## 1 50.00 50.00
## 2 8.33 91.67
## 3 11.11 88.89
## 4 NA NA
## 5 6.67 90.00
## 6 5.56 94.44
## MFN.Specific.Tariff.Lines.Share.... MFN.AVE.Tariff.Lines.Share....
## 1 0 0.00
## 2 0 0.00
## 3 0 0.00
## 4 NA NA
## 5 0 3.33
## 6 0 0.00
## MFN.MaxRate.... MFN.MinRate.... MFN.SpecificDuty.Imports..US..Thousand.
## 1 3.0 0 0
## 2 2.9 0 0
## 3 2.9 0 0
## 4 NA NA NA
## 5 3.0 0 0
## 6 2.9 0 0
## MFN.Dutiable.Imports..US..Thousand. MFN.Duty.Free.Imports..US..Thousand.
## 1 6.00 0.00
## 2 25.74 9329.78
## 3 149.07 3183.06
## 4 NA NA
## 5 13465.25 221735.41
## 6 1171.06 2600.56
##
## Attaching package: 'dplyr'
## The following object is masked from 'package:kableExtra':
##
## group_rows
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
library(scales)
#Aggregating total imports from each partner country
top_countries <- wits_partner %>%
filter(Trade.Flow == "Import") %>%
group_by(Partner.Name) %>%
summarise(Total_Import = sum(Import..US..Thousand.))
#Sorting the top countries by total import value
top_countries <- top_countries %>%
arrange(desc(Total_Import)) %>%
head(15) # Select the top 15 countries
#Creating a horizontal bar chart
ggplot(top_countries, aes(x = reorder(Partner.Name, Total_Import), y = Total_Import)) +
geom_bar(stat = "identity", fill = "skyblue") +
labs(title = "Top 15 Countries Importing to the US",
y = "Total Import (US$ Thousand)",
x = "Partner Country") +
scale_y_continuous(labels = comma) + # Format y-axis labels with commas
theme(axis.text.y = element_text(hjust = 1),
plot.title = element_text(hjust = 0.5)) +
coord_flip()library(dplyr)
library(ggplot2)
library(maps)
#Filtering the data for import flows
import_data <- wits_partner %>%
filter(Trade.Flow == "Import")
#Aggregating total imports from each partner country
import_sum <- import_data %>%
group_by(Partner.Name) %>%
summarise(Total_Import = sum(`Import..US..Thousand.`))
#Loading world map data
world_map <- map_data("world")
#Merging import data with world map data
import_map <- merge(world_map, import_sum, by.x = "region", by.y = "Partner.Name", all.x = TRUE)
#Creating a map plot
ggplot(import_map, aes(x = long, y = lat, group = group, fill = Total_Import)) +
geom_polygon(color = "transparent", size = 0.2) +
scale_fill_gradient(low = "lightblue", high = "darkblue", na.value = "grey", name = "Total Import (US$ Thousand)") +
labs(title = "Import Values from Countries Partnering with the US") +
theme_minimal() +
coord_fixed()## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
#Defining the alliance mapping
#Adding Brazil as a competitor
alliance_mapping <- list(
'Chile' = "Neutral",
'South Africa' = "Ally",
'Finland' = "Ally",
'Mexico' = "Neutral",
'Indonesia' = "Ally",
'Norway' = "Ally",
'Canada' = "Ally",
'Russia' = "Strained Relations",
'Japan' = "Ally",
'Philippines' = "Neutral",
'Peru' = "Neutral",
'Cuba' = "Strained Relations",
'Australia' = "Ally",
'Burma' = "Neutral",
'Portugal' = "Ally",
'Sweden' = "Ally",
'China' = "Strained Relations",
'Mauritania' = "Neutral",
'Brazil' = "Strained Relations",
'Argentina' = "Neutral",
'Germany' = "Ally",
'Namibia' = "Neutral",
'Zambia' = "Neutral",
'India' = "Neutral",
'Poland' = "Ally",
'Democratic Republic of Congo' = "Neutral",
'Vietnam' = "Neutral",
'Papua New Guinea' = "Neutral",
'Honduras' = "Neutral"
)
#Adding the 'status' column to wits_partner dataset
wits_partner$status <- unlist(lapply(wits_partner$Partner.Name, function(country) {
if (country %in% names(alliance_mapping)) {
return(alliance_mapping[[country]])
} else {
return("Neutral")
}
}))
#Checking the first few rows of the updated dataset
head(wits_partner)## Reporter.Name Partner.Name Year Trade.Flow Product.Group
## 1 United States Albania 2021 Import Minerals
## 2 United States United Arab Emirates 2021 Import Minerals
## 3 United States Argentina 2021 Import Minerals
## 4 United States Armenia 2021 Import Minerals
## 5 United States Australia 2021 Import Minerals
## 6 United States Austria 2021 Import Minerals
## Import..US..Thousand. Import.Product.Share.... AHS.Simple.Average....
## 1 6.00 0.01 0.00
## 2 103302.98 1.66 0.14
## 3 3428.89 0.06 0.00
## 4 49.98 0.06 NA
## 5 256115.59 2.16 0.00
## 6 4209.11 0.03 0.07
## AHS.Weighted.Average.... AHS.Total.Tariff.Lines
## 1 0.0 2
## 2 0.0 12
## 3 0.0 9
## 4 NA NA
## 5 0.0 30
## 6 0.3 18
## AHS.Dutiable.Tariff.Lines.Share.... AHS.Duty.Free.Tariff.Lines.Share....
## 1 0.00 100.00
## 2 8.33 91.67
## 3 0.00 100.00
## 4 NA NA
## 5 0.00 100.00
## 6 5.56 94.44
## AHS.Specific.Tariff.Lines.Share.... AHS.AVE.Tariff.Lines.Share....
## 1 0 0
## 2 0 0
## 3 0 0
## 4 NA NA
## 5 0 0
## 6 0 0
## AHS.MaxRate.... AHS.MinRate.... AHS.SpecificDuty.Imports..US..Thousand.
## 1 0.0 0 0
## 2 2.9 0 0
## 3 0.0 0 0
## 4 NA NA NA
## 5 0.0 0 0
## 6 2.9 0 0
## AHS.Dutiable.Imports..US..Thousand. AHS.Duty.Free.Imports..US..Thousand.
## 1 0.00 6.00
## 2 25.74 9329.78
## 3 0.00 3332.13
## 4 NA NA
## 5 0.00 235200.66
## 6 1171.06 2600.56
## MFN.Simple.Average.... MFN.Weighted.Average.... MFN.Total.Tariff.Lines
## 1 1.50 1.50 2
## 2 0.14 0.00 12
## 3 0.14 0.04 9
## 4 NA NA NA
## 5 0.23 0.06 30
## 6 0.07 0.30 18
## MFN.Dutiable.Tariff.Lines.Share.... MFN.Duty.Free.Tariff.Lines.Share....
## 1 50.00 50.00
## 2 8.33 91.67
## 3 11.11 88.89
## 4 NA NA
## 5 6.67 90.00
## 6 5.56 94.44
## MFN.Specific.Tariff.Lines.Share.... MFN.AVE.Tariff.Lines.Share....
## 1 0 0.00
## 2 0 0.00
## 3 0 0.00
## 4 NA NA
## 5 0 3.33
## 6 0 0.00
## MFN.MaxRate.... MFN.MinRate.... MFN.SpecificDuty.Imports..US..Thousand.
## 1 3.0 0 0
## 2 2.9 0 0
## 3 2.9 0 0
## 4 NA NA NA
## 5 3.0 0 0
## 6 2.9 0 0
## MFN.Dutiable.Imports..US..Thousand. MFN.Duty.Free.Imports..US..Thousand.
## 1 6.00 0.00
## 2 25.74 9329.78
## 3 149.07 3183.06
## 4 NA NA
## 5 13465.25 221735.41
## 6 1171.06 2600.56
## status
## 1 Neutral
## 2 Neutral
## 3 Neutral
## 4 Neutral
## 5 Ally
## 6 Neutral
library(ggplot2)
library(maps)
#Loading world map data
world_map <- map_data("world")
#Merging world map data with wits_partner dataset
map_data <- merge(world_map, wits_partner, by.x = "region", by.y = "Partner.Name", all.x = TRUE)
#Creating a map plot with color-coded alliance status
ggplot(map_data, aes(x = long, y = lat, group = group, fill = status)) +
geom_polygon(color = "transparent", size = 0.2) +
scale_fill_manual(values = c("Ally" = "blue", "Competitor" = "red", "Neutral" = "green"),
na.value = "grey", name = "Status",
labels = c("Ally", "Competitor", "Neutral")) +
labs(title = "Alliance Status of Countries",
fill = "Status") +
theme_minimal() +
coord_fixed() +
theme(legend.position = "bottom") # Move legend to the bottom of the plotlibrary(ggplot2)
library(maps)
#Loading world map data
world_map <- map_data("world")
#Merging world map data with wits_partner dataset
map_data <- merge(world_map, wits_partner, by.x = "region", by.y = "Partner.Name", all.x = TRUE)
#Creating a map plot with color-coded alliance status
ggplot(map_data, aes(x = long, y = lat, group = group, fill = status)) +
geom_polygon(color = "transparent", size = 0.2) +
scale_fill_manual(values = c("Ally" = "blue", "Strained Relations" = "red", "Neutral" = "green"),
na.value = "grey", name = "Status",
labels = c("Ally", "Competitors", "Neutral")) +
labs(title = "Alliance Status of Countries",
fill = "Status") +
theme_minimal() +
coord_fixed() +
theme(legend.position = "bottom") # Move legend to the bottom of the plotlibrary(dplyr)
library(ggplot2)
#Filtering the data by status and aggregate total imports
status_imports <- wits_partner %>%
group_by(status, Partner.Name) %>%
summarise(Total_Import = sum(`Import..US..Thousand.`)) %>%
arrange(desc(Total_Import)) %>%
group_by(status) %>%
top_n(10)## `summarise()` has grouped output by 'status'. You can override using the
## `.groups` argument.
## Selecting by Total_Import
#Creating separate plots for each status
ally_plot <- ggplot(filter(status_imports, status == "Ally"), aes(x = reorder(Partner.Name, Total_Import), y = Total_Import)) +
geom_bar(stat = "identity", fill = "blue") +
labs(title = "Top 5 Ally Countries Importing to the US",
y = "Total Import (US$ Thousand)",
x = "Partner Country") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
competitor_plot <- ggplot(filter(status_imports, status == "Strained Relations"), aes(x = reorder(Partner.Name, Total_Import), y = Total_Import)) +
geom_bar(stat = "identity", fill = "red") +
labs(title = "Top 5 Competitor Countries Importing to the US",
y = "Total Import (US$ Thousand)",
x = "Partner Country") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
neutral_plot <- ggplot(filter(status_imports, status == "Neutral"), aes(x = reorder(Partner.Name, Total_Import), y = Total_Import)) +
geom_bar(stat = "identity", fill = "green") +
labs(title = "Top 5 Neutral Countries Importing to the US",
y = "Total Import (US$ Thousand)",
x = "Partner Country") +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
#Displaying the plots
ally_plotIn conclusion, the analysis of mineral demand and import data provides valuable insights into the strategic importance of critical minerals for the United States. Key findings:
Importance of Critical Minerals: The US Geological Survey identifies certain minerals as critical due to their essential role in national security and economic prosperity. These minerals are crucial for various industries, including clean energy technologies like solar PV, wind power, electric vehicles, and grid battery storage.
Dependency on Foreign Sources: Despite their importance, many critical minerals are sourced from outside the US. This dependency raises concerns about supply chain vulnerabilities, especially during times of geopolitical tension, economic crises, or trade disruptions.
Categorization of Source Countries: As part of the assignment, each source country for critical minerals needs to be categorized as an ally, competitor, or neutral party. Understanding the geopolitical dynamics of mineral sourcing is essential for assessing reliability under stressed circumstances.
Mineral Commodity Summaries 2023: https://pubs.usgs.gov/publication/mcs2023