-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathother_plots.Rmd
45 lines (34 loc) · 1.13 KB
/
other_plots.Rmd
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
---
title: "Other Plots"
author: "Alejandra Gerosa"
date: "9/3/2019"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(readxl)
```
## R Markdown
```{r drafts}
data <- read_xlsx("data/mpd2018.xlsx", sheet = 2)
gdp_with_rankings <- data %>%
group_by(year) %>%
mutate(rank = row_number(desc(rgdpnapc)),
perc_rank = percent_rank(desc(rgdpnapc)),
rank_better_ties = rank(desc(rgdpnapc), ties.method = "min", na.last = "keep"))
rank_plot <- gdp_with_rankings %>%
filter(year >= 1850, countrycode %in% comparisons) %>%
ggplot(aes(year, rank, color = country))
rank_plot + geom_line() +
facet_wrap(~country) + guides(color = FALSE) +
geom_vline(xintercept = 1950, color = "pink") +
geom_vline(xintercept = 1975, color = "pink")
perc_rank_plot <- gdp_with_rankings %>%
filter(year >= 1850, countrycode %in% comparisons) %>%
ggplot(aes(year, perc_rank, color = country))
perc_rank_plot + geom_line() +
facet_wrap(~country) + guides(color = FALSE) +
geom_vline(xintercept = 1950, color = "pink") +
geom_vline(xintercept = 1975, color = "pink")
```