-
Notifications
You must be signed in to change notification settings - Fork 6
/
usa_vs_ussr_log.R
131 lines (117 loc) · 4.77 KB
/
usa_vs_ussr_log.R
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
library(tidyr)
library(dplyr)
library(readr)
library(ggplot2)
library(mosaic)
library(haven)
library(readxl)
library(zoo)
GDPdata <- read_excel("what_can_markets_do/mpd_2013-01.xlsx", col_names = TRUE)
names(GDPdata) <- gsub(" ", "_", names(GDPdata))
valid_column_names <- make.names(names=names(GDPdata), unique=TRUE, allow_ = TRUE)
names(GDPdata) <- valid_column_names
ColdWar <-
GDPdata %>%
select(Date, USA, F._USSR, S._Korea, Brazil) %>%#, Argentina_) %>%
#select(Date, USA, F._USSR_) %>%
rename(USSR = F._USSR, date = Date,
S.Korea = S._Korea) %>% #,
#Argentina = Argentina_) %>%
#rename(USSR = F._USSR_, date = Date) %>%
filter(date > 1912) %>%
gather(country, pcgdp, -date)
ColdWar <-
ColdWar %>%
mutate(pcgdp = na.approx(ColdWar$pcgdp)) %>%
mutate(period = ifelse(date > 1928 & date < 1940, 1,
ifelse(date > 1939 & date < 1946, 2, NA)
)
)
GreatDepression <-
ColdWar %>%
filter(date > 1928 & date < 1940)
WW2 <-
ColdWar %>%
filter(date > 1938 & date < 1946)
CWPlot <-
ColdWar %>%
ggplot(aes(x = date, y = pcgdp, group = country)) +
geom_line(aes(color = country)) +
scale_color_discrete("Country") +
scale_x_continuous(breaks = round(seq(min(ColdWar$date), max(ColdWar$date), by = 10),1)) +
ylab("Per Capita GDP (1990 International $)") +
xlab("Year") +
annotate("text", x = 1928, y = 4000, label = "First 5-year plan") +
geom_segment(aes(x = 1928, y = 3400, xend = 1928, yend = 1500),
size = 0.7, arrow = arrow(type = "closed",
length = unit(0.25, "cm"),
angle = 25)) +
annotate("text", x = 1933, y = 11000, label = "Great") +
annotate("text", x = 1933, y = 10000, label = "depression") +
geom_segment(aes(x = 1933, y = 9500, xend = 1933, yend = 5200),
size = 0.7, arrow = arrow(type = "closed",
length = unit(0.25, "cm"),
angle = 25)) +
annotate("text", x = 1945, y = 14500, label = "WWII Ends") +
geom_segment(aes(x = 1945, y = 14000, xend = 1945, yend = 12000),
size = 0.7, arrow = arrow(type = "closed",
length = unit(0.25, "cm"),
angle = 25)) +
annotate("text", x = 1959, y = 16000, label = "Kitchen Debate") +
geom_segment(aes(x = 1959, y = 15500, xend = 1959, yend = 11500),
size = 0.7, arrow = arrow(type = "closed",
length = unit(0.25, "cm"),
angle = 25)) +
annotate("text", x = 1991, y = 17000, label = "Central Planning") +
annotate("text", x = 1991, y = 16000, label = "Ends") +
geom_segment(aes(x = 1991, y = 15500, xend = 1991, yend = 7000),
size = 0.7, arrow = arrow(type = "closed",
length = unit(0.25, "cm"),
angle = 25)) +
#annotate("text", x = 2008, y = 16000, label = "Global") +
##annotate("text", x = 2008, y = 16000, label = "Financial") +
#annotate("text", x = 2008, y = 16000, label = "Crisis") +
#geom_segment(aes(x = 2008, y = 15500, xend = 1991, yend = 7000),
# size = 0.7, arrow = arrow(type = "closed",
# length = unit(0.25, "cm"),
# angle = 25)) +
theme_bw()
CWPlot +
geom_ribbon(data = GreatDepression,
aes(ymin = 0, ymax = pcgdp),
fill = "blue2", alpha = 0.75) +
geom_ribbon(data = WW2,
aes(ymin = 0, ymax = pcgdp),
fill = "grey70", alpha = 0.75)
pdf(file = "what_can_markets_do/usa_vs_ussr.pdf", width = 8, height = 6)
CWPlot
dev.off()
ColdWar2 <-
GDPdata %>%
select(Date, USA, F._USSR, S._Korea, Chile, Brazil) %>%#, Argentina_) %>%
#select(Date, USA, F._USSR_) %>%
rename(USSR = F._USSR, date = Date,
S.Korea = S._Korea) %>% #,
#Argentina = Argentina_) %>%
#rename(USSR = F._USSR_, date = Date) %>%
filter(date > 1912) %>%
gather(country, pcgdp, -date)
ColdWar2 <-
ColdWar2 %>%
mutate(pcgdp = na.approx(ColdWar$pcgdp)) %>%
mutate(period = ifelse(date > 1928 & date < 1940, 1,
ifelse(date > 1939 & date < 1946, 2, NA)
)
)
CWPlot2 <-
ColdWar2 %>%
ggplot(aes(x = date, y = pcgdp, group = country)) +
geom_line(aes(color = country)) +
scale_color_brewer( type = "qual", palette = "Set1", name = "Country") +
scale_x_continuous(breaks = round(seq(min(ColdWar$date), max(ColdWar$date), by = 20),1)) +
ylab("Per Capita GDP (1990 International $)") +
xlab("Year") +
theme_bw()
pdf(file = "capitalism/gdp_growth.pdf", width = 4, height = 3)
CWPlot2
dev.off()