library(tidyverse)
Source: the OECD.
dat <- readr::read_csv("../data/MSTI_PUB_17052018123824680.csv") %>%
dplyr::select(var = `MSTI Variables`, country = Country, year = YEAR, value = Value) %>%
dplyr::mutate(var = gsub("GERD as a percentage of GDP", "Total", var)) %>%
dplyr::mutate(var = gsub("Business-financed GERD as a percentage of GDP", "Business-financed", var)) %>%
dplyr::mutate(var = gsub("Government-financed GERD as a percentage of GDP", "Government-financed", var)) %>%
dplyr::mutate(value = value / 100)
ggplot(dat, aes(x = year, y = value, group = var, color = var)) +
geom_line(size = 1) +
facet_wrap(~country) +
scale_y_continuous(labels = scales::percent, lim = c(0, 0.04)) +
ylab("") +
ggtitle("GERD as a percentage of GDP") +
theme_minimal() + theme(legend.position="bottom",
legend.title = element_blank())
calc_index <- function(variable) {
dat_money <- readr::read_csv("../data/MSTI_PUB_17052018130111852.csv") %>%
dplyr::select(var = MSTI_VAR, country = Country, year = YEAR, value = Value) %>%
dplyr::filter(var == variable) %>%
dplyr::group_by(country) %>%
dplyr::mutate(index = value / value[1] * 100)
return(dat_money)
}
plot_index <- function(dat, title = NULL) {
ggplot(dat, aes(x = year, y = index, group = var, color = var)) +
geom_line(size = 1) +
facet_wrap(~country) +
scale_y_continuous() +
ylab("") +
ggtitle(title) +
theme_minimal() + theme(legend.position="bottom",
legend.title = element_blank())
}
# Total Government Allocations for R&D -- GBARD (current PPP $)
dat_gbard <- calc_index("C_PPP")
# Business Enterprise Expenditure on R&D -- BERD (current PPP $)
dat_berd <- calc_index("B_PPP")
# Higher Education Expenditure on R&D -- HERD (current PPP $)
dat_herd <- calc_index("H_PPP")
# Government Intramural Expenditure on R&D -- GOVERD (current PPP $)
dat_goverd <- calc_index("GV_PPP")
plot_index(dat_gbard, "Total Government Allocations for R&D (C_PPP)")
plot_index(dat_berd, "Business Enterprise Expenditure on R&D (B_PPP)")
plot_index(dat_herd, "Higher Education Expenditure on R&D (H_PPP)")
plot_index(dat_goverd, "Government Intramural Expenditure on R&D (GV_PPP)")
dat_fin <- readr::read_csv("../data/MSTI_PUB_17052018130111852.csv") %>%
dplyr::select(var = MSTI_VAR, country = Country, year = YEAR, value = Value) %>%
dplyr::filter(country == "Finland")
ggplot(dat_fin, aes(x = year, y = value, group = var, color = var)) +
geom_line(size = 1) +
ylab("Millions of $") +
theme_minimal() + theme(legend.position="bottom",
legend.title = element_blank())