-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
512 lines (512 loc) · 20.6 KB
/
.Rhistory
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
"3" = "somewhat interest in politics",
"4" = "very interest in politics")))
ggplot(reg_df, aes(x=sev, y=pol_trust)) +
geom_jitter(width=0.1, alpha=0.2) +
geom_smooth() +
facet_grid(. ~ pol_interest,
labeller=labeller(pol_interest = c("1" = "not at all interested in politics",
"2" = "not very interest in politics",
"3" = "somewhat interest in politics",
"4" = "very interest in politics")))
ggplot(reg_df, aes(x=sev, y=pol_trust)) +
geom_jitter(width=0.1, alpha=0.2) +
geom_smooth() +
facet_grid(. ~ pol_interest,
labeller=labeller(pol_interest = c("1" = "not at all interested in politics",
"2" = "not very interest in politics",
"3" = "somewhat interest in politics",
"4" = "very interest in politics"))) +
theme(plot.subtitle = element_text(size = 13),
plot.title = element_text(size = 15, face = "bold")) +
labs(title = "Political trust in national government vs. self-expression values, split by political interest",
x = "self-expression values index score",
y = "political trust", subtitle = "data: Asian Barometer Survey, wave 4, 2015/6")
ggplot(reg_df, aes(x=sev, y=pol_trust)) +
geom_jitter(width=0.1, alpha=0.2) +
geom_smooth() +
facet_grid(. ~ pol_interest,
labeller=labeller(pol_interest = c("1" = "not at all interested in politics",
"2" = "not very interested in politics",
"3" = "somewhat interested in politics",
"4" = "very interested in politics"))) +
theme(plot.subtitle = element_text(size = 13),
plot.title = element_text(size = 15, face = "bold")) +
labs(title = "Political trust in national government vs. self-expression values, split by political interest",
x = "self-expression values index score",
y = "political trust", subtitle = "data: Asian Barometer Survey, wave 4, 2015/6")
ggplot(reg_df, aes(x=sev, y=pol_trust)) +
geom_jitter(width=0.1, alpha=0.2) +
geom_smooth() +
facet_grid(. ~ pol_interest,
labeller=labeller(pol_interest = c("1" = "not at all interested in politics",
"2" = "not very interested in politics",
"3" = "somewhat interested in politics",
"4" = "very interested in politics"))) +
theme(plot.subtitle = element_text(size = 13),
plot.title = element_text(size = 15, face = "bold")) +
labs(title = "Political trust in national government vs. self-expression values (added noise), split by political interest",
x = "self-expression values index score",
y = "political trust", subtitle = "data: Asian Barometer Survey, wave 4, 2015/6")
plot_bivariate <- ggplot(reg_df, aes(x=sev, y=pol_trust)) +
geom_jitter(width=0.1, alpha=0.2) +
geom_smooth() +
facet_grid(. ~ pol_interest,
labeller=labeller(pol_interest = c("1" = "not at all interested in politics",
"2" = "not very interested in politics",
"3" = "somewhat interested in politics",
"4" = "very interested in politics"))) +
theme(plot.subtitle = element_text(size = 13),
plot.title = element_text(size = 15, face = "bold")) +
labs(title = "Political trust in national government vs. self-expression values (added noise), split by political interest",
x = "self-expression values index score",
y = "political trust", subtitle = "data: Asian Barometer Survey, wave 4, 2015/6")
ggsave('bivariate.png', path="./plots", plot=plot_trend, width=10, height=5, device="png")
ggsave('trend.png', path="./plots", plot=plot_trend, width=7.5, height=5, device="png")
ggsave('bivariate.png', path="./plots", plot=plot_bivariate, width=10, height=5, device="png")
ggsave('bivariate.png', path="./plots", plot=plot_bivariate, width=10, height=3.5, device="png")
plot_bivariate <- ggplot(reg_df, aes(x=sev, y=pol_trust)) +
geom_jitter(width=0.1, alpha=0.2) +
geom_smooth() +
facet_grid(. ~ pol_interest,
labeller=labeller(pol_interest = c("1" = "not at all interested in politics",
"2" = "not very interested in politics",
"3" = "somewhat interested in politics",
"4" = "very interested in politics"))) +
theme(plot.subtitle = element_text(size = 13),
plot.title = element_text(size = 15, face = "bold")) +
labs(title = "Political trust in national government vs. self-expression values",
x = "self-expression values index score",
y = "political trust", subtitle = "added noise, split by political interest [data: Asian Barometer Survey, wave 4, 2015/6]")
ggsave('bivariate.png', path="./plots", plot=plot_bivariate, width=10, height=3.5, device="png")
ggsave('bivariate.png', path="./plots", plot=plot_bivariate, width=10, height=5, device="png")
ggsave('bivariate.png', path="./plots", plot=plot_bivariate, width=10, height=3.5, device="png")
######################################################
#
# Political trust in national government in China
# am empirical analysis using data by the Asian Barometer Survey
#
# R script
#
#####################################################@
# Environment preparation ------------------------------------------------------------
# Clearing memory, setting language to English
rm(list = ls())
Sys.setenv(LANG = "en")
setwd(here::here())
# Loading packages
packages <- c(
"haven", #reading SPSS data
"readr", #dependency of haven
"here", #setting wd dynamically to root of current R project file. thus requires the use of RStudio projects alongside this script
"dplyr", #data manipulation
"Hmisc", #necessary for label() due to SPSS data
"ggplot2", #used for plots
"labelled", #necessary to remove labels
"naniar", #replacing specific values with NA
"data.table", #used for the setnames() function
"psych", #package necessary for the reverse.code() function
"flextable", #used to create summary table and to convert tables to docx
"gtsummary", #used to create summary tables
"stargazer" #used to create regression tables
)
installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) { # Install packages not yet installed
install.packages(packages[!installed_packages])
}
lapply(packages, library, character.only = TRUE) # Packages loading
# Loading and preparing Asian Barometer Survey data ------------------------------------------------------------
abs_wave1 <- read_sav(here("data_ABS", "ABSdata_PRC_wave1", "Mainland v4.2.sav"))
abs_wave2 <- read_sav(here("data_ABS", "ABSdata_PRC_wave2", "04_China.sav"))
abs_wave3 <- read_sav(here("data_ABS", "ABSdata_PRC_wave3", "ABS3w.CN.sav"))
abs_wave4 <- read_sav(here("data_ABS", "ABSdata_PRC_wave4", "W4_China_merged20181206.SAV"))
# View(abs_wave1)
# View(abs_wave2)
# View(abs_wave3)
# View(abs_wave4)
# Data transformation functions -------------------------------------------
#note that this function will only work on matrices, it will NOT work on data frames
rev <- function(data,variable) {
data <- psych::reverse.code(
keys = variable,
items = data)#,
#mini = min(data[,variable]), #apparently, reverse.code() finds this by default, but I will keep the code here
#maxi = max(data[,variable])) #apparently, reverse.code() finds this by default, but I will keep the code here
colnames(data)[which(colnames(data) == paste0(variable,"-"))] <- variable
return(data)
}
#supply a dataframe (data_list) and a CHARACTER vector (variable_list) that contains all the names of the vars to be reversed
rev_list <- function(data_list,variable_list,data,variable,log=TRUE) {
for (item in variable_list) {
data_list <- rev(
data=data_list,
variable=item)
if(log==TRUE){
print(paste0(
"Variable reversed: ", item, " (range is ", min(data_list[,item], na.rm = TRUE), ":", max(data_list[,item], na.rm = TRUE), ")"
))}
next
}
return(data_list)
}
rplc_NA <- function(data_list, variable_list, values,log=TRUE) {
for (item in variable_list) {
data_list <- naniar::replace_with_na(data_list, replace = list(item = values))
if(log==TRUE){
print(paste0(
"NA inserted for: ", item, " with values ", values
))}
next
}
}
# Time-series analysis: variable preparation -------------------------------------------
#these next few lines import the political trust variable from abs wave 1, 2, 3, and 4 respectively
#abs3 and 4 need to be recoded to match the rising likert scale of the other two variables
#first variable
trust_abs1 <- data.frame(pol_trust = abs_wave1$q008) %>%
remove_labels() %>%
naniar::replace_with_na(replace = list(pol_trust = c(0,98,99)))
trust_abs1$year = "2002"
#second variable
trust_abs2 <- data.frame(pol_trust = abs_wave2$q008) %>%
remove_labels() %>%
naniar::replace_with_na(replace = list(pol_trust = c(7,8,9)))
trust_abs2$year = "2007/8"
#third variable
trust_abs3 <- data.frame(pol_trust = abs_wave3$q9,
dummy = c(rep(NA,length(abs_wave3$q9)))) %>% #adding a dummy var b/c reverse.code() somehow doesn't work with atomic vectors
remove_labels() %>%
naniar::replace_with_na(replace = list(pol_trust = c(7,8,9)))
trust_abs3 <- rev_list(data_list=trust_abs3, variable_list="pol_trust")
trust_abs3 <- as.data.frame(trust_abs3)
trust_abs3$year = "2011"
trust_abs3 <- trust_abs3[,c(1,3)] #this gets rid of the dummy variable
#fourth variable
trust_abs4 <- data.frame(pol_trust = abs_wave4$q9,
dummy = c(rep(NA,length(abs_wave4$q9)))) %>% #adding a dummy var b/c reverse.code() somehow doesn't work with atomic vectors
remove_labels() %>%
naniar::replace_with_na(replace = list(pol_trust = c(-1,7,8,9))) %>%
rev_list(variable_list="pol_trust")
trust_abs4 <- as.data.frame(trust_abs4)
trust_abs4$year = "2015/6"
trust_abs4 <- trust_abs4[,c(1,3)] #this gets rid of the dummy variable
# Time-series analysis: data frame creation -------------------------------
#The next few lines combine the survey responses to the question about trust in national government
#After that, some summary statistics are created, such as count or proportion
#Multiple data frames are created to serve different visualization purposes
#first data frame
time_series_trust_raw <- rbind(trust_abs1,
trust_abs2,
trust_abs3,
trust_abs4)
#second data frame
time_series_trust_avg <- time_series_trust_raw %>%
group_by(year) %>%
summarise(avg = sprintf("%.2f", mean(pol_trust, na.rm = TRUE))) %>%
mutate(avg = as.numeric(avg))
#third data frame
time_series_trust <- time_series_trust_raw %>%
group_by(year, pol_trust) %>%
summarise(count = n()) %>%
left_join(y=time_series_trust_avg, by="year") %>%
group_by(year) %>%
summarise(pol_trust = pol_trust,
count = count,
avg = avg,
year_total = sum(count),
year_prop = count / year_total) %>%
mutate(
dummy = "dummy",
avg = avg,
year = as.factor(year),
pol_trust = factor(recode(pol_trust,
"1" = "no trust at all",
"2" = "not very much trust",
"3" = "quite a lot of trust",
"4" = "a great deal of trust"),
ordered = TRUE,
levels = c(
NA,
"a great deal of trust",
"quite a lot of trust",
"not very much trust",
"no trust at all"),
exclude = NULL
)
)
# Time-series analysis: visualization -------------------------------------
#This creates a table that displays the number of responses
table_freq <-
unclass(
table(
mutate(time_series_trust_raw,
pol_trust = factor(recode(pol_trust,
"1" = "no trust at all",
"2" = "not very much trust",
"3" = "quite a lot of trust",
"4" = "a great deal of trust"),
ordered = TRUE,
levels = c(
NA,
"a great deal of trust",
"quite a lot of trust",
"not very much trust",
"no trust at all"),
exclude = NULL
)
),
useNA="ifany")
)
vars <- "missing"
vars[2:5] <- row.names(table_freq)[2:5]
vars
table_freq <- as.data.frame(table_freq)
table_freq$Response <- vars
table_freq <- table_freq[,c("Response",
names(table_freq)[names(table_freq) != "Response"])]
rownames(table_freq) <- NULL
table_freq <- flextable::flextable(table_freq)
#This creates a bar plot that visualizes the survey responses across all years
plot_prop <- ggplot(data=time_series_trust) +
geom_bar(mapping=aes(x=year, y=year_prop, fill=pol_trust), stat = "identity", color = "black") +
scale_fill_manual(aesthetics="fill",
values=c(rgb(0.1,0.1,1.0,0.6),
rgb(0.3,0.0,0.7,0.6),
rgb(0.7,0.0,0.4,0.6),
rgb(1.0,0.0,0.2,0.6))) +
theme(plot.subtitle = element_text(size = 12),
panel.grid.minor = element_line(linetype = "blank"),
plot.title = element_text(size = 15)) +labs(title = "Political trust in national government in China",
x = NULL, y = "proportion of total survey responses",
fill = NULL, subtitle = "survey response breakdown by year [data: Asian Barometer Survey, waves 1-4]")
#This creates a bar plot that visualizes the averages across all years
plot_trend <- ggplot(data=time_series_trust_avg) +
geom_bar(mapping=aes(x=year, y=avg), stat="identity", fill=rgb(0.6,0.6,0.6,0.6)) +
geom_text(mapping=aes(x=year, y=avg, label=avg), position=position_dodge(width=0.9), vjust=2.5, size=6) +
coord_cartesian(ylim=c(1,4)) +
theme(plot.subtitle = element_text(size = 11),
panel.grid.minor = element_line(linetype = "blank"),
plot.title = element_text(size = 15)) +labs(title = "Political trust in national government in China",
x = NULL, y = "average", subtitle = "average survey responses per year [data: Asian Barometer Survey, waves 1-4]")
# Regression analysis: data frame creation --------------------------------------------------------------
reg_df <- data.frame(abs_wave4) %>%
select(se3_2, se2, se5a, se9, ir13, q1, q41, q118, q155, q161, q62, q57, q49, q148, q76, q81, q24, se7a, q44) %>%
cbind(pol_trust = trust_abs4$pol_trust) %>%
remove_labels() %>%
naniar::replace_with_na_at(.vars = c("se3_2", "se2","ir13"),
condition = ~.x %in% -1) %>%
naniar::replace_with_na_at(.vars = "se5a",
condition = ~.x %in% c(-1, 90, 98, 99)) %>%
naniar::replace_with_na_at(.vars = "se9",
condition = ~.x %in% c(-1, 9)) %>%
naniar::replace_with_na_at(.vars = "se7a",
condition = ~.x %in% c(-1, 0, 8, 9)) %>%
naniar::replace_with_na_at(.vars = c("q118", "q44"),
condition = ~.x %in% c(-1, 8, 9)) %>%
naniar::replace_with_na_at(.vars = c("q1", "q155", "q161", "q62", "q57", "q148", "q76", "q81", "q24", "q9"),
condition = ~.x %in% c(-1, 7, 8, 9)) %>%
naniar::replace_with_na_at(.vars = "q41",
condition = ~.x %in% c(-1, 5, 7, 8, 9)) %>%
naniar::replace_with_na_at(.vars = "q49",
condition = ~.x %in% c(-1, 97, 98, 99)) %>%
mutate(ir13 = recode(ir13, "1" = "1", "2" = "1", "3" = "1", "4" = "2"),
q76 = recode(q76, "1" = "1", "2" = "2.666", "3" = "4"),
q81 = recode(q81, "1" = "1", "2" = "4"))
reg_df <- as.data.frame(sapply(reg_df, as.numeric))
reg_df <- rev_list(data_list = reg_df,
variable_list = c("q81",
"q76",
"q161",
"q62",
"q57",
"q49",
"q148",
"q24",
"q44",
"q1"))
reg_df <- as.data.frame(reg_df)
setnames(reg_df,
old =c(
"se3_2", "se2", "se5a", "se9","ir13", #demographic controls
"q1", "q41", "q118", "q155", #regime performance
"q161", "q62", "q57", #cultural factors
"q49", #internet use
"q148", "q76", "q81", "q24", "se7a", #self-expression values components
"q44" #political interest
),
new =c(
"age", "female", "education_y", "unemployed","rural", #demographic controls
"economic_perf", "healthcare", "corruption", "unfairness_income_dist", #regime performance
"patriotism", "respect_for_authority", "allocentric_selfinterest", #cultural factors
"internet_use", #internet use
"diversity_tolerance", "civic_protest", "free_media", "general_trust", "weak_religiousness", #self-expression values components
"pol_interest" #political interest
)
)
reg_df$sev <- as.numeric(sprintf("%.2f",
rowMeans(reg_df[,c("diversity_tolerance", "civic_protest", "free_media", "general_trust", "weak_religiousness")], na.rm=TRUE)))
reg_df <- mutate(reg_df,
moderation_effect = pol_interest*sev)
# Regression analysis: model calculation ---------------------------------------------
#the following lines set up name vectors to make the regression syntax tidier
demographic_controls <- c("age", "female", "education_y", "unemployed","rural")
regime_performance <- c("economic_perf", "healthcare", "corruption", "unfairness_income_dist")
cultural_factors <- c("patriotism", "respect_for_authority", "allocentric_selfinterest")
internet_use <- "internet_use"
sev <- "sev"
sev_components <- c("diversity_tolerance", "civic_protest", "free_media", "general_trust", "weak_religiousness")
pol_interest <- "pol_interest"
moderation_effect <- "moderation_effect"
pol_trust <- "pol_trust"
m1 <- lm(
reformulate(
termlabels = c(
demographic_controls,
regime_performance,
cultural_factors,
internet_use,
sev),
response = pol_trust),
data = reg_df)
m2 <- lm(
reformulate(
termlabels = c(
demographic_controls,
regime_performance,
cultural_factors,
internet_use,
sev,
pol_interest),
response = pol_trust),
data = reg_df)
m3 <- lm(
reformulate(
termlabels = c(
demographic_controls,
regime_performance,
cultural_factors,
internet_use,
moderation_effect),
response = pol_trust),
data = reg_df)
m4 <- lm(
reformulate(
termlabels = c(
demographic_controls,
regime_performance,
cultural_factors,
internet_use,
sev,
pol_interest,
moderation_effect),
response = pol_trust),
data = reg_df)
m5 <- lm(
reformulate(
termlabels = c(
demographic_controls,
regime_performance,
cultural_factors,
internet_use,
sev_components),
response = pol_trust),
data = reg_df)
m6 <- lm(
reformulate(
termlabels = c(
demographic_controls,
regime_performance,
cultural_factors,
internet_use,
sev_components,
pol_interest),
response = pol_trust),
data = reg_df)
# Regression analysis: visualizations -------------------------------------
#this creates a table that summarizes the original, untransformed variables from ABS wave 4
table_summary0 <- gtsummary::tbl_summary(haven::as_factor(abs_wave4[,c("se3_2", "se2", "se5a", "se9", "ir13",
"q1", "q41", "q118", "q155", "q161",
"q62", "q57", "q49", "q148", "q76",
"q81", "q24", "se7a", "q44", "q9")])) %>%
bold_labels()
#this creates a table that summarizes the variables in the regression data frame
table_summary1 <- gtsummary::tbl_summary(reg_df) %>%
bold_labels()
dir.create("./plots")
#this creates a more concise table that summarizes the variables in the regression data frame
tabe_summary2 <- stargazer::stargazer(reg_df, type="html", out="plots/summary.html", omit.summary.stat = c("p25","p75"), digits=2,
covariate.labels = c(
"Age", "Female", "Formal education years", "Is unemployed","Rural residence",
"Economic performance", "Healthcare", "Corruption", "Unfairness of income distribution",
"Patriotism", "Respect for authority", "Allocentric self-interest",
"Internet use",
"(SEV) Tolerance for diversity", "(SEV) Inclination to civic protest", "(SEV) Preference for free media", "(SEV) Generalized social trust","(SEV) Weak religiousness",
"Political interest",
"Political trust",
"Self-expression values index",
"SE values * political interest"
))
tabe_reg1 <- stargazer::stargazer(m3,m4,m1,m2,
type="html",
title="OLS model, dependent variable: political trust in national government",
out="plots/regression1.html",
dep.var.caption = "",
dep.var.labels.include=FALSE,
single.row = TRUE,
covariate.labels = c(
"Age", "Female", "Formal education years", "Is unemployed","Rural residence",
"Economic performance", "Healthcare", "Corruption", "Unfairness of income distribution",
"Patriotism", "Respect for authority", "Allocentric self-interest",
"Internet use",
"Self-expression values index",
"Political interest",
"SE values * political interest"
))
plot_bivariate
a <- c("1" = "not at all interested in politics",
"2" = "not very interest in politics",
"3" = "somewhat interest in politics",
"4" = "very interest in politics")
b <- c("abc","dcgd")
table_reg2 <- stargazer::stargazer(m5,m6,
type="html",
title="OLS model, dependent variable: political trust in national government",
out="plots/regression2.html",
dep.var.caption = "",
dep.var.labels.include=FALSE,
single.row = TRUE,
covariate.labels = c(
"Age", "Female", "Formal education years", "Is unemployed","Rural residence",
"Economic performance", "Healthcare", "Corruption", "Unfairness of income distribution",
"Patriotism", "Respect for authority", "Allocentric self-interest",
"Internet use",
"(SEV) Tolerance for diversity", "(SEV) Inclination to civic protest", "(SEV) Preference for free media", "(SEV) Generalized social trust","(SEV) Weak religiousness",
"Political interest"
))
plot_bivariate <- ggplot(reg_df, aes(x=sev, y=pol_trust)) +
geom_jitter(width=0.1, alpha=0.2) +
geom_smooth() +
facet_grid(. ~ pol_interest,
labeller=labeller(pol_interest = c("1" = "not at all interested in politics",
"2" = "not very interested in politics",
"3" = "somewhat interested in politics",
"4" = "very interested in politics"))) +
theme(plot.subtitle = element_text(size = 13),
plot.title = element_text(size = 15, face = "bold")) +
labs(title = "Political trust in national government vs. self-expression values",
x = "self-expression values index score",
y = "political trust", subtitle = "added noise, split by political interest [data: Asian Barometer Survey, wave 4, 2015/6]")
# Plot and table output ---------------------------------------------------
table_freq
plot_prop
plot_trend
table_summary1
plot_bivariate
save_as_docx(table_freq, path="plots/freq.docx")
ggsave('prop.png', path="./plots", plot=plot_prop, width=7.5, height=5, device="png")
ggsave('trend.png', path="./plots", plot=plot_trend, width=7.5, height=5, device="png")
ggsave('bivariate.png', path="./plots", plot=plot_bivariate, width=10, height=3.5, device="png")
table_summary0 %>% as_flex_table() %>% flextable::save_as_docx(path="plots/summary0.docx")
table_summary1 %>% as_flex_table() %>% flextable::save_as_docx(path="plots/summary1.docx")
table_summary2
table_reg1
table_reg2