-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.qmd
146 lines (126 loc) · 5.67 KB
/
index.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
---
title: "Correlates of War Analysis"
execute:
echo: false
message: false
---
```{r}
#| message: false
#| echo: false
library(tidyverse)
stateSystem <-read_csv("majors2016.csv")
# Create a column with start and end dates
majors <- stateSystem %>%
mutate(start_date = as.Date(paste(styear, stmonth, stday, sep = "-")),
end_date = as.Date(paste(endyear, endmonth, endday, sep = "-")))
# Plot the timelines for each country
# ggplot(majors, aes(x = start_date, xend = end_date, y = stateabb, yend = stateabb, color = stateabb)) +
# geom_segment(linewidth = 2) +
# labs(title = "Timeline of Countries' Presence in the Dataset",
# x = "Year",
# y = "Country") +
# theme_minimal() +
# theme(legend.position = "none")
# Create a sequence of all years from the earliest to the latest
all_years <- seq(min(majors$styear), max(majors$endyear))
# Create a dataframe with counts of active countries for each year
active_countries <- map_dfr(all_years, function(year) {
tibble(
year = year,
active_countries = sum(majors$styear <= year & majors$endyear >= year)
)
})
#
# # Plot the count of active countries over time
# ggplot(active_countries, aes(x = year, y = active_countries)) +
# geom_line(color = "blue", size = 1) +
# labs(title = "Number of Active Countries Over Time",
# x = "Year",
# y = "Number of Active Countries") +
# theme_minimal()
```
```{r}
#| message: false
#| echo: false
library(tidyverse)
library(scales)
library(plotly)
majors<-read_csv("NMC-60-abridged.csv")
major_countries <- c("USA", "UKG", "FRN", "GMY", "AUH","ITA","RUS","CHN","JPN")
NMC <- majors %>% filter(stateabb %in% major_countries)
NMC$year <- as.factor(NMC$year)
NMC$year <- as.integer(NMC$year)
NMC$year <- (NMC$year+1815)
NMC <- NMC[NMC$milex > 0,]
# Plot 1: Military expenditure over time for all countries
NMCplot <- ggplot(NMC, aes(x = year, y = milex, group = stateabb, color = stateabb)) +
geom_line() +
labs(title = "Military Expenditure Over Time", x = "Year", y = "Military Expenditure (log scale)", color="State") +
scale_x_continuous() +
scale_y_log10(labels = dollar_format(prefix = "$")) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
axis.title.x = element_text(size = 12, face = "bold"),
axis.title.y = element_text(size = 12, face = "bold"),
legend.title = element_text(size = 10, face = "bold"),
legend.text = element_text(size = 8)
)
interactive_NMCplot <- ggplotly(NMCplot+xlim(1816,2016))
interactive_NMCplot
interactive_NMCplot1 <- ggplotly(NMCplot+xlim(1816,1900))
interactive_NMCplot1
interactive_NMCplot2 <- ggplotly(NMCplot+xlim(1900,2016))
interactive_NMCplot2
modern_countries <- c("USA","RUS","CHN","JPN")
gNMC <- NMC %>% filter(stateabb %in% modern_countries)
gNMCplot <- ggplotly(ggplot(gNMC, aes(x = year, y = milex, group = stateabb, color = stateabb)) +
geom_line() +
labs(title = "Military Expenditure Over Time (1816-2016)", x = "Year", y = "Military Expenditure (log scale)", color="State") +
scale_x_continuous() +
scale_y_log10(labels = dollar_format(prefix = "$")) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
axis.title.x = element_text(size = 12, face = "bold"),
axis.title.y = element_text(size = 12, face = "bold"),
legend.title = element_text(size = 10, face = "bold"),
legend.text = element_text(size = 8)
))
gNMCplot
euro <- c("UKG","GMY","ITA","AUH","FRN")
eNMC <- NMC %>% filter(stateabb %in% euro)
eNMCplot <- ggplotly(ggplot(eNMC, aes(x = year, y = milex, group = stateabb, color = stateabb)) +
geom_line() +
labs(title = "Military Expenditure Over Time (1816-2016)", x = "Year", y = "Military Expenditure (log scale)", color="State") +
scale_x_continuous() +
scale_y_log10(labels = dollar_format(prefix = "$")) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
axis.title.x = element_text(size = 12, face = "bold"),
axis.title.y = element_text(size = 12, face = "bold"),
legend.title = element_text(size = 10, face = "bold"),
legend.text = element_text(size = 8)
))
eNMCplot
# Save the plot as an image
# ggsave("enhanced_plot.png", p, width = 10, height = 6)
# Display the plot
# print(p)
#
# # Plot 2: Distribution of military personnel across countries
# ggplot(NMC, aes(x = stateabb, y = milper)) +
# geom_boxplot() +
# labs(title = "Distribution of Military Personnel Across Countries", x = "Country", y = "Military Personnel") +
# theme_minimal()
#
# # Plot 3: Relationship between military expenditure and military personnel
# NMC |> drop_na() |>
# ggplot(aes(x = milper, y = milex, color = stateabb)) +
# geom_point() +
# labs(title = "Relationship Between Military Expenditure and Personnel", x = "Military Personnel", y = "Military Expenditure") +
# theme_minimal()
```
The military expenditures of major powers have varied significantly over the past two centuries. The following data was pulled from the Correlates of War Project on National Materiel Capabilities. Mapping of data was then used to visualize and analyze the evolution of spending over time by country. Since the end of the Cold War, Russian military spending has been falling while Chinese military spending has been rising relative to American military spending.
This plot, using data from the Correlates of War study, displays military expenditures over time on a log scale for 9 countries recorded as "great powers" at some point in the dataset: Austria-Hungary, China, France, Germany, Italy, Japan, Russia, the United Kingdom, and the United States. If a country was not at that time considered a "great power," its figures are not displayed.