-
Notifications
You must be signed in to change notification settings - Fork 0
/
testTwoDfsMerge.R
111 lines (73 loc) · 2.38 KB
/
testTwoDfsMerge.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
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
# libraries survival analysis
library(survival)
library(survminer)
library(survMisc)
library(simPH)
library(flexsurv)
# libraries general
library(tidymodels)
library(tidyverse)
library(lubridate)
library(Amelia)
library(xtable)
library(haven)
library(foreign)
library(broom)
library(psych)
library(Hmisc)
library(expss)
library(rockchalk)
library(effects)
library(modeldata)
library(randomForest)
library(compare)
library(psych)
library(desc)
########################################### import relevant dfs
# import dta bergmann df
dtaBerg <- as_tibble(read_dta(file = "/Users/flo/Documents/Uni/Uni Bamberg/WS 2020-21/S Koalitionsforschung/data/cabinets_2019_Bergmann.dta"))
# dtaBerg linux:
dtaBergL <- as_tibble(read_dta(file = "/home/fw/Downloads/cabinets_2019_Bergmann.dta"))
### str(dtaBerg)
### View(dtaBerg)
head(dtaBerg)
# import xls ERDDA df
erdda <- as_tibble(readxl::read_excel(path = "/Users/flo/Desktop/data/erdda/Data ERD-e_SA_SOE_JH_N-29_2014.xls"))
# erdda linux:
erddaL <- as_tibble(readxl::read_excel(path = "/home/fw/Downloads/Data ERD-e_SA_SOE_JH_N-29_2014.xls"))
### str(erdda)
### View(erdda)
head(erdda)
########################################### filter
# linux
berg1PartyMinL <- filter(dtaBergL, dtaBergL$one_party_minor == 1 & dtaBergL$post_election_cabinet == 1)
#
bergCabMinL <- filter(dtaBergL, dtaBergL$minor_coalition == 1 & dtaBergL$post_election_cabinet == 1)
fre(bergCabMinL$discr2019)
# yes == 1 (33 obs), no == 0 (10 obs)
fre(berg1PartyMinL$discr2019)
# yes == 1 (49 obs); no == 0 (23 obs)
# macOS
berg1PartyMin <- filter(dtaBerg, dtaBerg$one_party_minor == 1 & dtaBerg$post_election_cabinet == 1)
#
bergCabMin <- filter(dtaBerg, dtaBerg$minor_coalition == 1 & dtaBerg$post_election_cabinet == 1)
fre(bergCabMin$discr2019)
# yes == 1 (33 obs), no == 0 (10 obs)
fre(berg1PartyMin$discr2019)
# yes == 1 (49 obs); no == 0 (23 obs)
########################################### df joins
# macOS
########## join via cab_code, as it is the same in both, of course
BerJoi <- full_join(berg1PartyMin, bergCabMin, by = NULL)
fre(BerJoi$discr2019)
########## filter for technical termination reasons: techn2019
BerJoi <- BerJoi %>% filter(techn2019 == 0)
fre(BerJoi$discr2019)
fre(BerJoi$techn2019)
fre(BerJoi$positive_parl)
##########
# well, it seems to work now...
# see:
## yes == 1 (33 obs); no == 0 (82 obs)
## just like i wanted it to work: adds the numbers up
##### EOD