Nuclear weapons exist. Some countries have them. Lots of countries
wish they had them.
For this project we shall take a took at the proliferation of nuclear
weapons since their creation at the end of the Second World War and
their usage after the war up to the modern era.
How many countries have attempted to obtain nuclear weapons and of
those how many have failed?
Are trends in weapon testing more easily linked to global effects or
regional ones?
By using geographical and historical context we will attempt to
visualize patterns of the nuclear arms race.
ggplot2 for plotting
rgeos and rworldmap for geographical cooridanates
tibble for some easy data frame reshaping
dplyr for easy data manipulation
library(ggplot2)
library(rgeos)
library(rworldmap)
library(tibble)
library(dplyr)
This dataset of Nuclear Weapons was obtained from Kaggle in the form
of four files.
https://www.kaggle.com/datasets/michaelbryantds/nuclear-weapons-dataset
We load in the four csv files as data frames.
dataPath <- "nuclear_weapons/"
dataList <- list.files(path = dataPath)
print(dataList)
[1] "nuclear_weapons_proliferation_owid.csv" "nuclear_weapons_proliferation_total_owid.csv"
[3] "nuclear_weapons_stockpiles.csv" "nuclear_weapons_tests_states.csv"
Assign data frame for each data file.
for(i in 1:length(dataList)) {
fileName <- substr(dataList[[i]],1,nchar(dataList[[i]])-4)
csv_path <- paste0(dataPath,dataList[[i]])
assign(paste0("data_", fileName), read.csv(csv_path))
}
rm(list = c("csv_path","fileName","i"))
dfList <- c()
for(i in 1:length(dataList)) {
dataset <- paste0("data_",as.character(dataList[i]))
dataset <- substr(dataset, 1, nchar(dataset)-4)
dfList[i] <- dataset
}
Quick look at the data.
for(i in 1:length(dfList)) {
print(c(dfList[i], str(get(dfList[i]))))
}
'data.frame': 16848 obs. of 6 variables:
$ country_name : chr "Abkhazia" "Abkhazia" "Abkhazia" "Abkhazia" ...
$ year : int 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 ...
$ nuclear_weapons_status : int 0 0 0 0 0 0 0 0 0 0 ...
$ nuclear_weapons_consideration: int 0 0 0 0 0 0 0 0 0 0 ...
$ nuclear_weapons_pursuit : int 0 0 0 0 0 0 0 0 0 0 ...
$ nuclear_weapons_possession : int 0 0 0 0 0 0 0 0 0 0 ...
[1] "data_nuclear_weapons_proliferation_owid"
'data.frame': 85 obs. of 5 variables:
$ entity_name : chr "World" "World" "World" "World" ...
$ year : int 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 ...
$ number_nuclweap_consideration: int 0 2 3 3 3 2 2 5 3 4 ...
$ number_nuclweap_pursuit : int 0 0 0 1 2 3 3 2 2 2 ...
$ number_nuclweap_possession : int 0 0 0 0 0 0 0 1 1 1 ...
[1] "data_nuclear_weapons_proliferation_total_owid"
'data.frame': 780 obs. of 3 variables:
$ country_name : chr "China" "China" "China" "China" ...
$ year : int 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 ...
$ nuclear_weapons_stockpile: int 0 0 0 0 0 0 0 0 0 0 ...
[1] "data_nuclear_weapons_stockpiles"
'data.frame': 600 obs. of 3 variables:
$ country_name : chr "China" "China" "China" "China" ...
$ year : int 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 ...
$ nuclear_weapons_tests: int 0 0 0 0 0 0 0 0 0 0 ...
[1] "data_nuclear_weapons_tests_states"
Convert “country_name” columns from character to factor.
data_nuclear_weapons_proliferation_owid$country_name <-
factor(data_nuclear_weapons_proliferation_owid$country_name)
data_nuclear_weapons_stockpiles$country_name <-
factor(data_nuclear_weapons_stockpiles$country_name)
data_nuclear_weapons_tests_states$country_name <-
factor(data_nuclear_weapons_tests_states$country_name)
We can easily plot the countries in pursuit of and in possession of
nuclear arms together.
fills <- c("Possession" = "steelblue", "Pursuit" = "goldenrod2")
ggplot(data_nuclear_weapons_proliferation_total_owid, aes(x=year)) +
geom_col(aes(y = number_nuclweap_possession, fill = "Possession"),
color="steelblue4") +
geom_col(aes(y = number_nuclweap_pursuit, fill="Pursuit"),
color="sienna",
alpha=0.8) +
scale_fill_manual(values=fills, name="Status") +
scale_y_continuous(breaks=c(0:9)) +
scale_x_continuous(breaks = seq(1941,2022,9)) +
theme(
panel.grid.minor.y = element_blank(),
panel.grid.major = element_line(color="grey80"),
panel.background = element_rect(fill="white", color ="black"),
plot.background = element_rect(fill="white", color="white")) +
xlab("Year") + ylab("Number of Countries") +
ggtitle("Global Nuclear Weapon States")
We can see that possession of nuclear weapons has gradually increased
over time resulting in 9 countries possessing nuclear arms in the modern
era.
When a country in pursuit succeeds in their goals, they are removed
from the “pursuit pool” and added to the pool of those in possession of
nuclear arms. Not all countries who have actively pursued these weapons
have succeeded however.
considered <- data_nuclear_weapons_proliferation_owid[
data_nuclear_weapons_proliferation_owid$nuclear_weapons_status > 0,]
considered$country_name <-
factor(considered$country_name)
ggplot(considered,
aes(x=year,
y=country_name,
fill=factor(nuclear_weapons_status))) +
geom_tile(aes(height=0.85)) +
xlab("Year") + ylab("Country") +
scale_fill_manual(values = c("springgreen4","orange1","steelblue3"),
name="Status",
labels=c("Consideration","Pursuit","Possession")) +
scale_x_continuous(breaks=seq(1938,2022,12)) +
geom_vline(
xintercept=considered[max(considered$nuclear_weapons_status),]$year) +
ggtitle(label = "Global Consideration of Nuclear Weapons") +
theme_bw()
Here we see a more detailed view of all countries that have publicly
considered attempting to obtain nuclear weapons.
1985 was the year that had the most countries labeled as either
considering, pursuing, or in possession of nuclear weapons.
As of today, Iran remains the only country still actively pursuing
nuclear weaponry.
When did each country have their record stockpile size?
max_stockpile <- data_nuclear_weapons_stockpiles %>%
group_by(country_name) %>% slice(which.max(nuclear_weapons_stockpile))
ggplot(max_stockpile,
aes(x=reorder(country_name, nuclear_weapons_stockpile),
y=nuclear_weapons_stockpile,
fill = nuclear_weapons_stockpile)) +
geom_bar(stat="identity", color="black") +
geom_text(aes(label=year, y = min(nuclear_weapons_stockpile)),
vjust=7, size=3) +
scale_y_log10(breaks=10^(0:5),
expand=c(0,0.5),
labels=c("0","10","100","1,000","10,000","100,000")) +
scale_fill_distiller(palette="RdBu",
name="Stockpiled Weapons") +
ylab(label="Number of Nuclear Weapons") +
ggtitle(label="Maximum Nuclear Weapon Stockpile Size") +
theme(
axis.text.x = element_text(angle=30, hjust =0.8, vjust=0.8, size=10),
axis.title.x = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.major.y = element_line(color="grey80"),
panel.background = element_rect(fill="white", color="black"),
legend.title = element_text(vjust=3))
Clearly Russia and the United States are far beyond the rest of the
pack in regards to the size of their nuclear weapons stockpile.
Lots of weapons back 70’s and 80’s. What happened?
total_stockpile <- data_nuclear_weapons_stockpiles[
data_nuclear_weapons_stockpiles$country_name %in%
c("United States", "Russia"),] %>%
group_by(year, country_name) %>% summarise(nuclear_weapons_stockpile)
ggplot(total_stockpile, aes(x=year,
y=nuclear_weapons_stockpile,
fill=country_name)) +
geom_col(position = "stack") +
scale_x_continuous(breaks=seq(1945,2022,7)) +
scale_y_continuous(limits=c(0,70000),
breaks=seq(0,70000, 10000),
labels=c("0",
"10,000",
"20,000",
"30,000",
"40,000",
"50,000",
"60,000",
"70,000")) +
scale_fill_brewer(palette="Set1",name="Country") +
xlab(label="Year") + ylab(label="Number of Nuclear Weapons") +
geom_vline(xintercept=1991) +
annotate("text", x = 2002, y = 60000, label="Post-Soviet Era") +
ggtitle(label="USA/Russia Nuclear Weapon Stockpile Over Time") +
theme_bw()
The stockpile of the major player’s decreased dramatically in the
90’s before tapering off to a stable level that has remained consistent
after 2008.
Lets look at just the current year with a different perspective.
First we need to figure out where all these countries are. We start by
getting the centroid positions of all countries.
wmap <- getMap(resolution="low")
centroids <- gCentroid(wmap, byid=TRUE)
centroid_df <- as.data.frame(centroids)
head(centroid_df)
Turn the index into a column.
centroid_df <- rownames_to_column(centroid_df, "Country")
# Rename USA to be consistent
centroid_df["Country"][centroid_df["Country"] == "United States of America"] <- "United States"
head(centroid_df)
Merge nuclear stockpile data for 2022 with centroids of
countries.
stockpile_df <- subset(data_nuclear_weapons_stockpiles, data_nuclear_weapons_stockpiles$year==2022)
stockpile_df <- merge(stockpile_df, centroid_df, by.x="country_name", by.y="Country")
# remove South Africa since they don't have any weapons currently.
stockpile_df <- stockpile_df[ !stockpile_df$country_name=="South Africa", ]
head(stockpile_df)
We can now use these coordinates to show this global arms race on the
next best thing to a globe: a map.
world <-map_data("world")
ggplot() +
geom_map(
data = world, map = world,
aes(long,lat, map_id=region),
color="white", fill = "grey80", linewidth=0.01) +
geom_point(
data=stockpile_df,
aes(x, y, size=nuclear_weapons_stockpile, fill=nuclear_weapons_stockpile),
shape = 21, color="gold") +
scale_size("Stockpiled Weapons", range=c(5,20), guide="none") +
scale_fill_distiller("Stockpiled Weapons", palette = "RdBu") +
ggtitle("Global Nuclear Weapon Stockpiles: 2022") +
theme(
axis.text=element_blank(),
axis.ticks=element_blank(),
axis.title=element_blank(),
panel.grid=element_blank(),
panel.background=element_rect(fill="white", color="black"))
ggsave("2022Stockpile.png")
We will take a closer look at the United States and Russia.
Specifically the testing of their weapons in the field.
usa_russia_tests <-
data_nuclear_weapons_tests_states[
data_nuclear_weapons_tests_states$country_name %in% c("United States", "Russia"),]
usa_russia_tests$country_name <-
factor(usa_russia_tests$country_name)
summary(usa_russia_tests$nuclear_weapons_tests)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0.00 0.00 2.00 11.63 18.00 96.00
Those 96 tests in one year seem to be a slight outlier.
ggplot(usa_russia_tests,aes(x=year, y=nuclear_weapons_tests))+
geom_line(aes(color=country_name), size=0.75) +
scale_color_brewer(palette = "Set1", name="Country") +
scale_x_continuous(limits = c(1944, 1994),breaks = seq(1945,1993,6)) +
xlab("Year") + ylab("Number of Nuclear Weapon Tests") +
ggtitle("Global Superpower Nuclear Weapon Testing") +
annotate("rect", xmin=1962,
xmax=1964,ymin=0,ymax=100,alpha=0.15,fill="grey",color="gold") +
annotate("text", x = 1975, y = 85, label="1963 Partial Test Ban Treaty") +
annotate("rect", xmin=1957.5, xmax=1959, ymin=0, ymax=100, alpha=0.05,
fill="grey50", color="gold") +
annotate("text", x = 1952, y = 65, label="1958 Testing") +
annotate("text", x = 1952, y = 60, label="Moratorium") +
theme(
panel.grid.minor.y=element_blank(),
panel.grid.major.y=element_line(color="grey75"),
panel.grid.major.x = element_blank(),
legend.key = element_rect(fill="white"),
panel.background=element_rect(fill="white", color="black"),
plot.background=element_rect(fill="white"))
ggsave("AmericaRussiaTesting.png")
Testing by both the United States and the former Soviet Union had
large spikes in 1958 and 1963 followed immediately by a massive
decrease.
Both of these slowdowns can be associated with treaties between the
two superpowers, the first one not nearly as binding as the the more
formal Partial Test Ban Treaty that was signed after the Cuban Missile
Crisis.
Lets examine regional relationships among some of the other nuclear
powers.
india_pakistan_stockpile <-
data_nuclear_weapons_stockpiles[
data_nuclear_weapons_stockpiles$country_name %in% c("India", "Pakistan"),]
india_pakistan_stockpile$country_name <-
factor(india_pakistan_stockpile$country_name)
Since the start date isn’t obvious this time, let us check when we
should start our timeline.
max(india_pakistan_stockpile$year[
(india_pakistan_stockpile$nuclear_weapons_stockpile==0) &
india_pakistan_stockpile$country_name=="India"])
[1] 1997
max(india_pakistan_stockpile$year[
(india_pakistan_stockpile$nuclear_weapons_stockpile==0) &
india_pakistan_stockpile$country_name=="Pakistan"])
[1] 1997
We can focus the timeline range from 1997 to 2022.
ggplot(india_pakistan_stockpile,aes(x=year))+
geom_line(aes(color=country_name,y=nuclear_weapons_stockpile),size=0.75) +
scale_color_manual(name="Country",
values=c("darkorange", "darkgreen")) +
scale_x_continuous(limits = c(1995, 2023),breaks = seq(1996,2022,2)) +
xlab("Year") + ylab("Number of Nuclear Weapons") +
ggtitle("Nuclear Stockpiles of India and Pakistan") +
theme(
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill="white", color = "grey40"),
legend.background = element_rect(fill="white", color="white"),
legend.key = element_rect(fill="white", color="white"),
)
ggsave("IndiaPakistanStockpile.png")
India and Pakistan have increased their stockpiles at approximately
the same rate and at the same scale.
From this exploration we see the obvious indications of geopolitics being a dominating factor in the proliferation of nuclear weapons.
The scale of the global nuclear arms race is skewed by the presence of the Cold War superpowers. While neither Russia nor the United States are actively contributing to the growth of the total nuclear stockpile, they still remain the clear largest shareholders of the global atomic horde.
And while the scale of the overall nuclear-arms race has decreased dramatically since the latter half of the Cold War, regional races are still ongoing and the real life ramifications of the usage of nuclear arms can not be conveyed with the data used in this project.