全コードは、必要に応じて右上のタブで表示されたい。
# setup library
Packages <- c("tidyverse", "DT", "OECD")
lapply(Packages, library, character.only = TRUE)
# import data
df1_tidy <- readRDS("~/R/Musashi_University/2021_first_semester/Economic_English/Data/df1_tidy.RDS")
df2_tidy <- readRDS("~/R/Musashi_University/2021_first_semester/Economic_English/Data/df2_tidy.RDS")g1 <- ggplot(df1_tidy, aes(t_mfp, t_gdphrs_v, colour = location)) +
geom_point() +
theme(legend.position = "none")
print(g1)df1_tidy %>%
pivot_longer(cols = c(-"location", -"obs_time")) %>%
ggplot(aes(obs_time, value, colour = name, group = name)) +
geom_point()# liner regression --------------------------------------------------------
df1_model <-
df1_tidy %>%
filter(location %in% c("AUT", "JPN")) %>%
group_by(location) %>%
nest() %>%
mutate(model = map(data, ~lm(t_mfp ~ t_gdphrs_v + t_hrspop + t_ulch, data = .)) %>%
setNames(c(location))
)
library(gtsummary) #http://www.danieldsjoberg.com/gtsummary/articles/tbl_regression.html
tbl_regression(df1_model$model[[1]]) %>%
add_global_p() %>%
bold_p(t = 0.05) %>%
modify_caption(location[1])
tbl_regression(df1_model$model[[2]]) %>%
add_global_p() %>%
bold_p(t = 0.05) %>%
modify_caption(location[2])