forked from mmuratardag/AC_ArdagOneyCohrs_2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path00_data_prep_3_desp_stats_data_vis.R
66 lines (53 loc) · 2.87 KB
/
00_data_prep_3_desp_stats_data_vis.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
load("data/ISSP_NI_M23.RData")
library(tidyverse)
library(psych)
library(knitr)
ds_tab <- as_tibble(describe(d[,12:41])) %>% select(n:se)
ds_tab$n <- 1-(ds_tab$n/65630)
ds_tab %>% select(n:median,min:max,skew:se) %>% rename(miss_perc = n) %>% kable(digits = 3)
library(reshape2)
ggplot(melt(d [, c(12:41)]), aes(x=value)) + geom_histogram() + facet_wrap(~variable) + theme_bw()
library(janitor)
ct_d <- d %>% tabyl(cntr, time)
ct_d %>% adorn_percentages("row") %>% adorn_pct_formatting(digits = 1) %>% adorn_ns() %>% kable()
df <- d %>% select(cntr, time) %>% group_by(cntr, time) %>% summarise(counts = n())
ggplot(df, aes(x = cntr, y = counts)) +
geom_bar(aes(color = time, fill = time), stat = "identity") +
theme_bw() +
#scale_color_manual(values = c("#0073C2FF", "#EFC000FF"))+
#scale_fill_manual(values = c("#0073C2FF", "#EFC000FF")) +
geom_text(aes(label = counts, group = time), color = "white") +
#ggrepel::geom_label_repel(label=df$counts, size=2, check_overlap = T) +
xlab("Sample % of Country by time") +
ylab("Frequency") +
labs(title="National Identity Modules 2 & 3",
caption = "Source: International Social Survey Program")
library(strengejacke)
plot_frq(d$cntr, sort.frq = "asc", type = "bar", geom.colors = "grey", vjust = "middle") +
theme_bw() +
xlab("Sample % of Country by time") +
ylab("Frequency") +
labs(title="National Identity Modules 2 & 3",
caption = "Source: International Social Survey Program")
library(readxl)
cld <- read_excel("data/00_data_prep.R_country_level_data_wQs.xlsx")
unique(cld$country)
n_distinct(cld$country) # 24
`%notin%` <- Negate(`%in%`)
cld <- cld %>% filter(country%notin%c("JP", "CH", "TW"))
unique(cld$country)
n_distinct(cld$country) # 21
gdp <- cld %>% ggplot(aes(x=GDPPPP)) + geom_histogram() + theme_bw() + ggtitle("GDP per capita T1 (2003) & T2 (2013)")
gdp_bar <- cld %>% ggplot(aes(x=GDPPPP_q)) + geom_bar() + theme_bw() + ggtitle("GDP per capita T1 (2003) & T2 (2013) Binarized")
gini <- cld %>% ggplot(aes(x=GINI)) + geom_histogram() + theme_bw() + ggtitle("GINI T1 (2003) & T2 (2013)")
gini_bar <- cld %>% ggplot(aes(x=GINI_q)) + geom_bar() + theme_bw() + ggtitle("GINI T1 (2003) & T2 (2013) Binarized")
LibD <- cld %>% ggplot(aes(x=LibD)) + geom_histogram() + theme_bw() + ggtitle("vDEM Liberal Democracy Score T1 (2003) & T2 (2013)")
LibD_bar <- cld %>% ggplot(aes(x=libD_q)) + geom_bar() + theme_bw() + ggtitle("vDEM Liberal Democracy Score T1 (2003) & T2 (2013) Binarized")
EgaD <- cld %>% ggplot(aes(x=EgaD)) + geom_histogram() + theme_bw() + ggtitle("vDEM Egalitarian Democracy Score T1 (2003) & T2 (2013)")
EgaD_bar <- cld %>% ggplot(aes(x=egaD_q)) + geom_bar() + theme_bw() + ggtitle("vDEM Egalitarian Democracy Score T1 (2003) & T2 (2013) Binarized")
library(gridExtra)
grid.arrange(gdp,gdp_bar,
gini,gini_bar,
LibD,LibD_bar,
EgaD,EgaD_bar,
nrow=4, ncol=2)