forked from lpstntw/2018_Taiwan_Local_Election
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocal_Election_for_Report.Rmd
More file actions
1008 lines (881 loc) · 61.9 KB
/
Local_Election_for_Report.Rmd
File metadata and controls
1008 lines (881 loc) · 61.9 KB
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
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Local Election for Report"
author: "Po-Sheng Lee"
date: 2018-12-26
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)
library(tidyverse)
library(readxl)
library(magrittr)
```
```{r tidy2018 data}
#台北
taipei_2018 <- read_excel("data/縣表3-1-100(臺北市).xls")
taipei_2018 %<>%
rename("行政區別" = `107年臺北市市長選舉候選人在各投開票所得票數一覽表`, "里別" = X__1,
"民進黨候選人得票數" = X__5, "國民黨候選人得票數" = X__4, "無黨籍候選人得票數" = X__6,
"投票數" = X__10,"選舉人數"= X__14) %>%
map(~gsub('\\s+', '',x = .)) %>%
as_data_frame() %>%
mutate(選舉年份 = 2018, 縣市別 = "台北市",
國民黨候選人 = "丁守中", 民進黨候選人 = "姚文智", 無黨籍候選人 = "柯文哲",
民進黨候選人得票數 = as.numeric(民進黨候選人得票數),
國民黨候選人得票數 = as.numeric(國民黨候選人得票數),
無黨籍候選人得票數 = as.numeric(無黨籍候選人得票數),
選舉人數 = as.numeric(選舉人數),
投票數 = as.numeric(投票數)) %>%
select(選舉年份, 縣市別, 行政區別, 里別, 國民黨候選人, 民進黨候選人, 無黨籍候選人,
國民黨候選人得票數, 民進黨候選人得票數, 無黨籍候選人得票數, 投票數, 選舉人數) %>%
drop_na() %>%
group_by(行政區別, 里別) %>%
mutate(國民黨候選人得票數 = sum(國民黨候選人得票數), 民進黨候選人得票數 = sum(民進黨候選人得票數),
無黨籍候選人得票數 = sum(無黨籍候選人得票數),
選舉人數 = sum(選舉人數), 投票數 = sum(投票數)) %>%
distinct(行政區別, 里別, .keep_all = T) %>%
ungroup()
taipei_2018 %<>%
mutate(國民黨候選人得票率 = 國民黨候選人得票數/投票數, 民進黨候選人得票率 = 民進黨候選人得票數/投票數,
無黨籍候選人得票率 = 無黨籍候選人得票數/投票數, 投票率 = 投票數/選舉人數,
政黨色 = case_when(
國民黨候選人得票數 > 無黨籍候選人得票數 & 國民黨候選人得票數 > 民進黨候選人得票數 ~ "Blue",
無黨籍候選人得票數 > 國民黨候選人得票數 & 無黨籍候選人得票數 > 民進黨候選人得票數 ~ "Grey",
民進黨候選人得票數 > 無黨籍候選人得票數 & 民進黨候選人得票數 > 國民黨候選人得票數 ~ "Green"))
write_excel_csv(taipei_2018, "data/2018台北市候選人得票概況(村里別)")
#新北
newtaipei_2018 <- read_excel("data/縣表3-1-200(新北市).xls")
newtaipei_2018 %<>%
rename("行政區別" = `107年新北市市長選舉候選人在各投開票所得票數一覽表`, "里別" = X__1,
"民進黨候選人得票數" = X__3, "國民黨候選人得票數" = X__4,
"投票數" = X__7, "選舉人數" = X__11) %>%
map(~gsub('\\s+', '',x = .)) %>%
as_data_frame() %>%
mutate(選舉年份 = 2018, 縣市別 = "新北市", 國民黨候選人 = "侯友宜", 民進黨候選人 = "蘇貞昌",
民進黨候選人得票數 = as.numeric(民進黨候選人得票數),
國民黨候選人得票數 = as.numeric(國民黨候選人得票數),
投票數 = as.numeric(投票數),
選舉人數 = as.numeric(選舉人數)) %>%
select(選舉年份, 縣市別, 行政區別, 里別, 國民黨候選人, 民進黨候選人,
國民黨候選人得票數, 民進黨候選人得票數, 投票數, 選舉人數) %>%
drop_na() %>%
group_by(行政區別, 里別) %>%
mutate(國民黨候選人得票數 = sum(國民黨候選人得票數), 民進黨候選人得票數 = sum(民進黨候選人得票數),
投票數 = sum(投票數), 選舉人數 = sum(選舉人數)) %>%
distinct(行政區別, 里別, .keep_all = T) %>%
ungroup()
newtaipei_2018 %<>%
mutate(國民黨候選人得票率 = 國民黨候選人得票數/投票數, 民進黨候選人得票率 = 民進黨候選人得票數/投票數,
`得票率差(百分點)` = (國民黨候選人得票率 - 民進黨候選人得票率)*100,
得票數差 = 國民黨候選人得票數 - 民進黨候選人得票數, 投票率 = 投票數/選舉人數,
政黨色 = if_else(得票數差 > 0, "Blue", "Green"))
write_excel_csv(newtaipei_2018, "data/2018新北市候選人得票概況(村里別)")
#桃園
taoyuan_2018 <- read_excel("data/縣表3-1-300(桃園市).xls")
taoyuan_2018 %<>%
rename("行政區別" = `107年桃園市市長選舉候選人在各投開票所得票數一覽表`, "里別" = X__1,
"民進黨候選人得票數" = X__7, "國民黨候選人得票數" = X__4, "投票數" = X__10, "選舉人數" = X__14) %>%
map(~gsub('\\s+', '',x = .)) %>%
as_data_frame() %>%
mutate(選舉年份 = 2018, 縣市別 = "桃園市", 國民黨候選人 = "陳學聖", 民進黨候選人 = "鄭文燦",
民進黨候選人得票數 = as.numeric(民進黨候選人得票數),
國民黨候選人得票數 = as.numeric(國民黨候選人得票數),
投票數 = as.numeric(投票數),
選舉人數 = as.numeric(選舉人數)) %>%
select(選舉年份, 縣市別, 行政區別, 里別, 國民黨候選人, 民進黨候選人,
國民黨候選人得票數, 民進黨候選人得票數, 投票數, 選舉人數) %>%
drop_na() %>%
group_by(行政區別, 里別) %>%
mutate(國民黨候選人得票數 = sum(國民黨候選人得票數), 民進黨候選人得票數 = sum(民進黨候選人得票數),
投票數 = sum(投票數), 選舉人數 = sum(選舉人數)) %>%
distinct(行政區別, 里別, .keep_all = T) %>%
ungroup() %>%
mutate(國民黨候選人得票率 = 國民黨候選人得票數/投票數, 民進黨候選人得票率 = 民進黨候選人得票數/投票數,
`得票率差(百分點)` = (國民黨候選人得票率 - 民進黨候選人得票率)*100,
得票數差 = 國民黨候選人得票數 - 民進黨候選人得票數, 投票率 = 投票數/選舉人數,
政黨色 = if_else(得票數差 > 0, "Blue", "Green"))
write_excel_csv(taoyuan_2018, "data/2018桃園市候選人得票概況(村里別)")
#台中
taichung_2018 <- read_excel("data/縣表3-1-400(臺中市).xls")
taichung_2018 %<>%
rename("行政區別" = `107年臺中市市長選舉候選人在各投開票所得票數一覽表`, "里別" = X__1,
"民進黨候選人得票數" = X__4, "國民黨候選人得票數" = X__5, "投票數" = X__8, "選舉人數" = X__12) %>%
map(~gsub('\\s+', '',x = .)) %>%
as_data_frame() %>%
mutate(選舉年份 = 2018, 縣市別 = "台中市", 國民黨候選人 = "盧秀燕", 民進黨候選人 = "林佳龍",
民進黨候選人得票數 = as.numeric(民進黨候選人得票數),
國民黨候選人得票數 = as.numeric(國民黨候選人得票數),
投票數 = as.numeric(投票數),
選舉人數 = as.numeric(選舉人數)) %>%
select(選舉年份, 縣市別, 行政區別, 里別, 國民黨候選人, 民進黨候選人,
國民黨候選人得票數, 民進黨候選人得票數, 投票數, 選舉人數) %>%
drop_na() %>%
group_by(行政區別, 里別) %>%
mutate(國民黨候選人得票數 = sum(國民黨候選人得票數), 民進黨候選人得票數 = sum(民進黨候選人得票數),
投票數 = sum(投票數), 選舉人數 = sum(選舉人數)) %>%
distinct(行政區別, 里別, .keep_all = T) %>%
ungroup() %>%
mutate(國民黨候選人得票率 = 國民黨候選人得票數/投票數, 民進黨候選人得票率 = 民進黨候選人得票數/投票數,
`得票率差(百分點)` = (國民黨候選人得票率 - 民進黨候選人得票率)*100,
得票數差 = 國民黨候選人得票數 - 民進黨候選人得票數, 投票率 = 投票數/選舉人數,
政黨色 = if_else(得票數差 > 0, "Blue", "Green"))
write_excel_csv(taoyuan_2018, "data/2018台中市候選人得票概況(村里別)")
#台南
tainan_2018 <- read_excel("data/縣表3-1-500(臺南市).xls")
tainan_2018 %<>%
rename("行政區別" = `107年臺南市市長選舉候選人在各投開票所得票數一覽表`, "里別" = X__1,
"民進黨候選人得票數" = X__3, "國民黨候選人得票數" = X__4, "投票數" = X__11, "選舉人數" = X__15) %>%
map(~gsub('\\s+', '',x = .)) %>%
as_data_frame() %>%
mutate(選舉年份 = 2018, 縣市別 = "台南市", 國民黨候選人 = "高思博", 民進黨候選人 = "黃偉哲",
民進黨候選人得票數 = as.numeric(民進黨候選人得票數),
國民黨候選人得票數 = as.numeric(國民黨候選人得票數),
投票數 = as.numeric(投票數),
選舉人數 = as.numeric(選舉人數)) %>%
select(選舉年份, 縣市別, 行政區別, 里別, 國民黨候選人, 民進黨候選人,
國民黨候選人得票數, 民進黨候選人得票數, 投票數, 選舉人數) %>%
drop_na() %>%
group_by(行政區別, 里別) %>%
mutate(國民黨候選人得票數 = sum(國民黨候選人得票數), 民進黨候選人得票數 = sum(民進黨候選人得票數),
投票數 = sum(投票數), 選舉人數 = sum(選舉人數)) %>%
distinct(行政區別, 里別, .keep_all = T) %>%
ungroup() %>%
mutate(國民黨候選人得票率 = 國民黨候選人得票數/投票數, 民進黨候選人得票率 = 民進黨候選人得票數/投票數,
`得票率差(百分點)` = (國民黨候選人得票率 - 民進黨候選人得票率)*100,
得票數差 = 國民黨候選人得票數 - 民進黨候選人得票數, 投票率 = 投票數/選舉人數,
政黨色 = if_else(得票數差 > 0, "Blue", "Green"))
write_excel_csv(taoyuan_2018, "data/2018台南市候選人得票概況(村里別)")
#高雄
kaoshung_2018 <- read_excel("data/縣表3-1-600(高雄市).xls")
kaoshung_2018 %<>%
rename("行政區別" = `107年高雄市市長選舉候選人在各投開票所得票數一覽表`, "里別" = X__1,
"民進黨候選人得票數" = X__4, "國民黨候選人得票數" = X__3, "投票數" = X__9, "選舉人數" = X__13) %>%
# delete the white space for further use
# map function shortcut with ~
map(~gsub('\\s+', '',x = .)) %>%
as_data_frame() %>%
mutate(選舉年份 = 2018, 縣市別 = "高雄市", 國民黨候選人 = "韓國瑜", 民進黨候選人 = "陳其邁",
民進黨候選人得票數 = as.numeric(民進黨候選人得票數),
國民黨候選人得票數 = as.numeric(國民黨候選人得票數),
投票數 = as.numeric(投票數),
選舉人數 = as.numeric(選舉人數)) %>%
select(選舉年份, 縣市別, 行政區別, 里別, 國民黨候選人, 民進黨候選人,
國民黨候選人得票數, 民進黨候選人得票數, 投票數, 選舉人數) %>%
drop_na() %>%
group_by(行政區別, 里別) %>%
mutate(國民黨候選人得票數 = sum(國民黨候選人得票數), 民進黨候選人得票數 = sum(民進黨候選人得票數),
投票數 = sum(投票數), 選舉人數 = sum(選舉人數)) %>%
distinct(行政區別, 里別, .keep_all = T) %>%
ungroup() %>%
mutate(國民黨候選人得票率 = 國民黨候選人得票數/投票數, 民進黨候選人得票率 = 民進黨候選人得票數/投票數,
`得票率差(百分點)` = (國民黨候選人得票率 - 民進黨候選人得票率)*100,
得票數差 = 國民黨候選人得票數 - 民進黨候選人得票數, 投票率 = 投票數/選舉人數,
政黨色 = if_else(得票數差 > 0, "Blue", "Green"))
write_excel_csv(taoyuan_2018, "data/2018高雄市候選人得票概況(村里別)")
```
```{r data import}
taipei_2010 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2010台北")
taipei_2014 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2014台北")
newtaipei_2010 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2010新北") %>%
mutate(選舉年份 = as.numeric(選舉年份))
newtaipei_2014 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2014新北")
taoyuan_2009 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2009桃園")
taoyuan_2014 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2014桃園")
taichung_2010 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2010台中")
taichung_2014 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2014台中")
tainan_2010 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2010台南")
tainan_2014 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2014台南") %>%
rename("國民黨候選人得票率" = 民進黨候選人得票率, "民進黨候選人得票率" = 民進黨候選人得票率__1, )
kaoshung_2010 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2010高雄")
kaoshung_2014 <- read_excel("data/近3屆六都縣市長候選人得票概況(村里別).xlsx", sheet = "2014高雄")
```
```{r turnout 2010 and 2014}
turnout <- function(path){
t_2010 <- read_excel(path = path, skip = 1) %>%
rename(投票數 = `C
投票數
C=A+B`,
選舉人數 = `G
選舉人數
(原領票數)
G=E+F`) %>%
select(行政區別, 里別, 投票數, 選舉人數) %>%
map(~gsub('\\s+', '',x = .)) %>%
as_data_frame() %>%
mutate(投票數 = as.numeric(投票數), 選舉人數 = as.numeric(選舉人數)) %>%
drop_na() %>%
group_by(行政區別, 里別) %>%
mutate(投票數 = sum(投票數), 選舉人數 = sum(選舉人數)) %>%
distinct(行政區別, 里別, .keep_all = T) %>%
ungroup() %>%
mutate(投票率 = 投票數/選舉人數)
return(t_2010)
}
turnout_taipei_2010 <- turnout(path = "data/市表3-1-100(10臺北市).xls")
turnout_newtaipei_2010 <- turnout(path = "data/市表3-1-200(10新北市).xls")
turnout_taichung_2010 <- turnout(path = "data/市表3-1-300(10臺中市).xls")
turnout_tainan_2010 <- turnout(path = "data/市表3-1-400(10臺南市).xls")
turnout_kaoshung_2010 <- turnout(path = "data/市表3-1-500(10高雄市).xls")
turnout_taipei_2014 <- turnout(path = "data/縣表3-1-100(14臺北市)-候選人得票數一覽表.xls")
turnout_newtaipei_2014 <- turnout(path = "data/縣表3-1-200(14新北市)-候選人得票數一覽表.xls")
turnout_taoyuan_2014 <- turnout(path = "data/縣表3-1-300(14桃園市)-候選人得票數一覽表.xls")
turnout_taichung_2014 <- turnout(path = "data/縣表3-1-400(14臺中市)-候選人得票數一覽表.xls")
turnout_tainan_2014 <- turnout(path = "data/縣表3-1-500(14臺南市)-候選人得票數一覽表.xls")
turnout_kaoshung_2014 <- turnout(path = "data/縣表3-1-600(14高雄市)-候選人得票數一覽表.xls")
turnout_taoyuan_2010 <- read_excel("data/縣表3-1-303(09桃園縣).xls", skip = 1) %>%
rename(投票數 = `C
投票數
C=A+B`,
選舉人數 = `G
選舉人數
(原領票數)
G=E+F` ,
行政區別 = 鄉鎮市區別, 里別 = 村里別) %>%
select(行政區別, 里別, 投票數, 選舉人數) %>%
map(~gsub('\\s+', '',x = .)) %>%
as_data_frame() %>%
mutate(投票數 = as.numeric(投票數), 選舉人數 = as.numeric(選舉人數)) %>%
drop_na() %>%
group_by(行政區別, 里別) %>%
mutate(投票數 = sum(投票數), 選舉人數 = sum(選舉人數)) %>%
distinct(行政區別, 里別, .keep_all = T) %>%
ungroup() %>%
mutate(投票率 = 投票數/選舉人數)
```
```{r combine turnout to extant data}
turnout_combination <- function(city_data, turnout_data){
x <- city_data %>%
unite(行政區別, 里別, col = "neighbor", sep = "/")
y <- turnout_data %>%
select(-投票數) %>%
unite(行政區別, 里別, col = "neighbor", sep = "/")
z <- left_join(x = x, y = y, by = "neighbor") %>%
separate(neighbor, into = c("行政區別", "里別"))
}
taipei_2010 %<>%
turnout_combination(turnout_data = turnout_taipei_2010)
taipei_2014 %<>%
turnout_combination(turnout_data = turnout_taipei_2014)
newtaipei_2010 %<>%
turnout_combination(turnout_data = turnout_newtaipei_2010)
newtaipei_2014 %<>%
turnout_combination(turnout_data = turnout_newtaipei_2014)
taoyuan_2009 %<>%
turnout_combination(turnout_data = turnout_taoyuan_2010)
taoyuan_2014 %<>%
turnout_combination(turnout_data = turnout_taoyuan_2014)
taichung_2010 %<>%
turnout_combination(turnout_data = turnout_taichung_2010)
taichung_2014 %<>%
turnout_combination(turnout_data = turnout_taichung_2014)
tainan_2010 %<>%
turnout_combination(turnout_data = turnout_tainan_2010)
tainan_2014 %<>%
turnout_combination(turnout_data = turnout_tainan_2014)
kaoshung_2010 %<>%
turnout_combination(turnout_data = turnout_kaoshung_2010)
kaoshung_2014 %<>%
turnout_combination(turnout_data = turnout_kaoshung_2014)
```
```{r combine data}
vote_combination <- function(x_2010,x_2014,x_2018){
x_2010 %<>%
select(縣市別, 行政區別, 里別, 國民黨候選人得票數, 民進黨候選人得票數, 投票數,
國民黨候選人得票率, 民進黨候選人得票率, 選舉人數, 投票率) %>%
rename(city = 縣市別, district = 行政區別, neighbor = 里別,
KMTvote_2010 = 國民黨候選人得票數, DDPvote_2010 = 民進黨候選人得票數,
ballot_2010 = 投票數, KMTrate_2010 = 國民黨候選人得票率, DDPrate_2010 = 民進黨候選人得票率,
electorate_2010 = 選舉人數, turnout_2010 = 投票率) %>%
unite(city, district, neighbor, col = "neighbor", sep = "/")
x_2014 %<>%
select(縣市別, 行政區別, 里別, 國民黨候選人得票數, 民進黨候選人得票數, 投票數,
國民黨候選人得票率, 民進黨候選人得票率, 選舉人數, 投票率) %>%
rename(city = 縣市別, district = 行政區別, neighbor = 里別,
KMTvote_2014 = 國民黨候選人得票數, DDPvote_2014 = 民進黨候選人得票數, ballot_2014 = 投票數,
KMTrate_2014 = 國民黨候選人得票率, DDPrate_2014 = 民進黨候選人得票率,
electorate_2014 = 選舉人數, turnout_2014 = 投票率) %>%
unite(city, district, neighbor, col = "neighbor", sep = "/")
x_2018 %<>%
select(縣市別, 行政區別, 里別, 國民黨候選人得票數, 民進黨候選人得票數, 投票數,
國民黨候選人得票率, 民進黨候選人得票率, 選舉人數, 投票率) %>%
rename(city = 縣市別, district = 行政區別, neighbor = 里別,
KMTvote_2018 = 國民黨候選人得票數, DDPvote_2018 = 民進黨候選人得票數, ballot_2018 = 投票數,
KMTrate_2018 = 國民黨候選人得票率, DDPrate_2018 = 民進黨候選人得票率,
electorate_2018 = 選舉人數, turnout_2018 = 投票率) %>%
unite(city, district, neighbor, col = "neighbor", sep = "/")
z <- x_2018 %>%
left_join(x_2014, by = "neighbor") %>%
left_join(x_2010, by = "neighbor") %>%
separate(neighbor, into = c("city", "district", "neighbor"))
return(z)
}
newtaipei_2010_to_2018 <- vote_combination(newtaipei_2010, newtaipei_2014, newtaipei_2018)
taoyuan_2010_to_2018 <- vote_combination(taoyuan_2009, taoyuan_2014, taoyuan_2018)
taichung_2010_to_2018 <- vote_combination(taichung_2010, taichung_2014, taichung_2018)
tainan_2010_to_2018 <- vote_combination(tainan_2010, tainan_2014, tainan_2018)
kaoshung_working_2010 <- kaoshung_2010 %>%
select(縣市別, 行政區別, 里別, 國民黨候選人得票數, 民進黨候選人得票數, 無黨籍候選人得票數,
投票數, 國民黨候選人得票率, 民進黨候選人得票率, 無黨籍候選人得票率, 選舉人數, 投票率) %>%
rename(city = 縣市別, district = 行政區別, neighbor = 里別,
KMTvote_2010 = 國民黨候選人得票數, DDPvote_2010 = 民進黨候選人得票數, NPvote_2010 = 無黨籍候選人得票數,
ballot_2010 = 投票數, KMTrate_2010 = 國民黨候選人得票率, DDPrate_2010 = 民進黨候選人得票率,
NPrate_2010 = 無黨籍候選人得票率,
electorate_2010 = 選舉人數, turnout_2010 = 投票率) %>%
unite(city, district, neighbor, col = "neighbor", sep = "/") # For joining the data
kaoshung_working_2014 <- kaoshung_2014 %>%
select(縣市別, 行政區別, 里別, 國民黨候選人得票數, 民進黨候選人得票數, 投票數,
國民黨候選人得票率, 民進黨候選人得票率, 選舉人數, 投票率) %>%
rename(city = 縣市別, district = 行政區別, neighbor = 里別,
KMTvote_2014 = 國民黨候選人得票數, DDPvote_2014 = 民進黨候選人得票數, ballot_2014 = 投票數,
KMTrate_2014 = 國民黨候選人得票率, DDPrate_2014 = 民進黨候選人得票率,
electorate_2014 = 選舉人數, turnout_2014 = 投票率) %>%
unite(city, district, neighbor, col = "neighbor", sep = "/")
kaoshung_working_2018 <- kaoshung_2018 %>%
select(縣市別, 行政區別, 里別, 國民黨候選人得票數, 民進黨候選人得票數, 投票數,
國民黨候選人得票率, 民進黨候選人得票率, 選舉人數, 投票率) %>%
rename(city = 縣市別, district = 行政區別, neighbor = 里別,
KMTvote_2018 = 國民黨候選人得票數, DDPvote_2018 = 民進黨候選人得票數, ballot_2018 = 投票數,
KMTrate_2018 = 國民黨候選人得票率, DDPrate_2018 = 民進黨候選人得票率,
electorate_2018 = 選舉人數, turnout_2018 = 投票率) %>%
unite(city, district, neighbor, col = "neighbor", sep = "/")
kaoshung_2010_to_2018 <- kaoshung_working_2018 %>%
left_join(kaoshung_working_2014, by = "neighbor") %>%
left_join(kaoshung_working_2010, by = "neighbor") %>%
separate(neighbor, into = c("city", "district", "neighbor"))
taipei_working_2010 <- taipei_2010 %>%
select(縣市別, 行政區別, 里別, 國民黨候選人得票數, 民進黨候選人得票數, 投票數,
國民黨候選人得票率, 民進黨候選人得票率, 選舉人數, 投票率) %>%
rename(city = 縣市別, district = 行政區別, neighbor = 里別,
KMTvote_2010 = 國民黨候選人得票數, DDPvote_2010 = 民進黨候選人得票數, ballot_2010 = 投票數,
KMTrate_2010 = 國民黨候選人得票率, DDPrate_2010 = 民進黨候選人得票率,
electorate_2010 = 選舉人數, turnout_2010 = 投票率) %>%
unite(city, district, neighbor, col = "neighbor", sep = "/")
taipei_working_2014 <- taipei_2014 %>%
select(縣市別, 行政區別, 里別, 國民黨候選人得票數, 無黨籍候選人得票數,
投票數, 國民黨候選人得票率, 無黨籍候選人得票率, 選舉人數, 投票率) %>%
rename(city = 縣市別, district = 行政區別, neighbor = 里別,
KMTvote_2014 = 國民黨候選人得票數, NPvote_2014 = 無黨籍候選人得票數, ballot_2014 = 投票數,
KMTrate_2014 = 國民黨候選人得票率, NPrate_2014 = 無黨籍候選人得票率,
electorate_2014 = 選舉人數, turnout_2014 = 投票率) %>%
unite(city, district, neighbor, col = "neighbor", sep = "/")
taipei_working_2018 <- taipei_2018 %>%
select(縣市別, 行政區別, 里別, 國民黨候選人得票數, 民進黨候選人得票數, 無黨籍候選人得票數,
投票數, 國民黨候選人得票率, 民進黨候選人得票率, 無黨籍候選人得票率, 選舉人數, 投票率) %>%
rename(city = 縣市別, district = 行政區別, neighbor = 里別,
KMTvote_2018 = 國民黨候選人得票數, DDPvote_2018 = 民進黨候選人得票數, NPvote_2018 = 無黨籍候選人得票數,
ballot_2018 = 投票數, KMTrate_2018 = 國民黨候選人得票率, DDPrate_2018 = 民進黨候選人得票率,
NPrate_2018 = 無黨籍候選人得票率,
electorate_2018 = 選舉人數, turnout_2018 = 投票率) %>%
unite(city, district, neighbor, col = "neighbor", sep = "/")
taipei_2010_to_2018 <- taipei_working_2010 %>%
left_join(taipei_working_2014, by = "neighbor") %>%
left_join(taipei_working_2018, by = "neighbor") %>%
separate(neighbor, into = c("city", "district", "neighbor"))
taiwan_2010_to_2018 <- bind_rows(taipei_2010_to_2018, newtaipei_2010_to_2018,
taoyuan_2010_to_2018, taichung_2010_to_2018,
tainan_2010_to_2018, kaoshung_2010_to_2018)
#注意!!!台南2018年村里重劃 不要算2014-18的
write_excel_csv(taiwan_2010_to_2018, "data/台灣六都(台南除外)2010至18年市長選舉結果(村里別)")
taiwan_2018 <- bind_rows(taipei_2018, newtaipei_2018, taoyuan_2018, taichung_2018, tainan_2018, kaoshung_2018)
taiwan_2014 <- bind_rows(taipei_2014, newtaipei_2014, taoyuan_2014, taichung_2014, tainan_2014, kaoshung_2014)
taiwan_2010 <- bind_rows(taipei_2010, newtaipei_2010, taoyuan_2009, taichung_2010, tainan_2010, kaoshung_2010)
```
```{r mutate data}
taiwan_2010_to_2018 %<>%
mutate(KMTrsp_2010 = KMTvote_2010/electorate_2010, DDPrsp_2010 = DDPvote_2010/electorate_2010,
NPrsp_2010 = NPvote_2010/electorate_2010, KMTrsp_2014 = KMTvote_2014/electorate_2014,
DDPrsp_2014 = DDPvote_2014/electorate_2014, NPrsp_2014 = NPvote_2014/electorate_2014,
KMTrsp_2018 = KMTvote_2018/electorate_2018, DDPrsp_2018 = DDPvote_2018/electorate_2018,
NPrsp_2018 = NPvote_2018/electorate_2018,
ballot_10_to_14 = ballot_2014 - ballot_2010, ballot_14_to_18 = ballot_2018 - ballot_2014,
turnout_10_to_14 = turnout_2014 - turnout_2010, turnout_14_to_18 = turnout_2018 - turnout_2014,
DDPvote_10_to_14 = DDPvote_2014 - DDPvote_2010, DDPvote_14_to_18 = DDPvote_2018 - DDPvote_2014,
KMTvote_10_to_14 = KMTvote_2014 - KMTvote_2010, KMTvote_14_to_18 = KMTvote_2018 - KMTvote_2014,
NPvote_10_to_14 = NPvote_2014 - NPvote_2010, NPvote_14_to_18 = NPvote_2018 - NPvote_2014,
DDPrate_10_to_14 = DDPrate_2014 - DDPrate_2010, DDPrate_14_to_18 = DDPrate_2018 - DDPrate_2014,
KMTrate_10_to_14 = KMTrate_2014 - KMTrate_2010, KMTrate_14_to_18 = KMTrate_2018 - KMTrate_2014,
NPrate_10_to_14 = NPrate_2014 - NPrate_2010, NPrate_14_to_18 = NPrate_2018 - NPrate_2014,
DDPrsp_10_to_14 = DDPrsp_2014 - DDPrsp_2010, DDPrsp_14_to_18 = DDPrsp_2018 - DDPrsp_2014,
KMTrsp_10_to_14 = KMTrsp_2014 - KMTrsp_2010, KMTrsp_14_to_18 = KMTrsp_2018 - KMTrsp_2014,
NPrsp_10_to_14 = NPrsp_2014 - NPrsp_2010, NPrsp_14_to_18 = NPrsp_2018 - NPrsp_2014)
```
#前言
2018台灣地方選舉,結果對很多人來說應該很錯愕,對於進步派來說,明明改革已經在路上了,為何期中選舉還是烏鴉鴉,長期執政的高雄市以及2014年大幅獲勝的台中市為何都敗給保守又親中的國民黨?而對於心急如焚的台獨派來說,這不啻是一個對於這幾年改變的重重打臉,好像民眾仍然只想發大財而不管其他議題,或許對於進步派而言更令人失望的是, [外媒](https://www.bloomberg.com/news/articles/2018-11-25/pro-china-party-s-big-win-in-taiwan-puts-tsai-future-in-doubt) 都傾向於將這次選舉的結果解釋成中國勢力的勝利。市面上目前已經夠多文章談論民進黨為何失敗,從黨內 [青回陣](https://tw.appledaily.com/new/realtime/20181219/1486215/?fbclid=IwAR2RcbUPgX3Of8PLhEl6uWdSMstpLDtumKD9xLiaWxQb9K3Ryn4GlY7hufQ) 認為*改革無感*是選舉失敗的主因,然而不少人都認為,同婚議題才是民進黨掉票的主因。而林宗弘團隊基於 [縣市數據](https://twstreetcorner.org/2018/11/29/linthunghong-5/) 的推論是認為軍公教改革與農業改革的反撲,跟同婚沒什麼關係。而張育誠最近於菜市場政治學發表的 [文章](http://whogovernstw.org/2018/12/25/yuchenchang4/?fbclid=IwAR0wQXK7xSN79FfTaHlUTiWinr_95QeKKVUydJFAsfEMjWXs80pjgovRiV4) ,用區位資料反推個體可能投票意向,結果顯示,這次選舉在大部分選區都是民進黨不出來投票,真正發生選民結構變動的地方並不多。本文基本上循著張育誠文章的邏輯,以觀察2010-2018年六都的 [^1] 投票率變化、真實支持率 [^2] 。本文的簡單結論是,在中南部選區,問題不是2018年選太差,而是2014年選的異常的好。
##資料來源與方法
本文2010年與2014年的資料主要來自 [這裡](https://hackmd.io/73-uzN0CTr6r5waEAQfmpw?view&fbclid=IwAR0-bn0S3e9bZM1V8mdx2NliFIQCkVHImoYUomixXC2oIOSA74M0ijYus58),其中章魚哥的整理。並且加上中選會網站的原始資料以及我自己的整理。
本篇主要都是敘述性的繪圖,沒有利用推論統計(無論是線性模型推論或是生態推論)。推論統計如果作者有空的話會再嘗試處理,沒空就算了。
#2010選舉概況
2010年地方選舉是本文設定為比較基準的選舉,以下幾張圖的X軸是各里投票率而Y軸是各里的實質支持率。我們可以看到,國民黨在六都的實質支持率都不太隨著投票率有顯著的變化,相關係數很小。而民進黨則是隨著投票率增加會有較高的支持率。簡單的解釋就是,民進黨相對較倚賴熱情出來投票的支持者,而國民黨則是有比較穩定的票源(不論是穩定的高或是穩定的低)
```{r 2010 選舉}
taiwan_2010_to_2018 %>%
filter(city == "台北市") %>%
ggplot(aes(x = turnout_2010)) +
geom_point(aes(y = KMTrsp_2010), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2010), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2010), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2010), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2010年投票率與支持率(台北市)", x = "2010年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "新北市") %>%
ggplot(aes(x = turnout_2010)) +
geom_point(aes(y = KMTrsp_2010), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2010), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2010), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2010), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2010年投票率與支持率(新北市)", x = "2010年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "桃園市") %>%
ggplot(aes(x = turnout_2010)) +
geom_point(aes(y = KMTrsp_2010), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2010), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2010), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2010), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2009年投票率與支持率(桃園縣)", x = "2009年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台中市") %>%
ggplot(aes(x = turnout_2010)) +
geom_point(aes(y = KMTrsp_2010), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2010), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2010), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2010), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2010年投票率與支持率(台中市)", x = "2010年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台南市") %>%
ggplot(aes(x = turnout_2010)) +
geom_point(aes(y = KMTrsp_2010), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2010), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2010), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2010), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2010年投票率與支持率(台南市)", x = "2010年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>% # 藍營為楊秋興加上黃昭順
filter(city == "高雄市") %>%
ggplot(aes(x = turnout_2010)) +
geom_point(aes(y = KMTrsp_2010 + NPrsp_2010), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2010 + NPrsp_2010), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2010), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2010), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2010年投票率與支持率(高雄市)", x = "2010年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
```
#2014選舉概況
簡單來說,2014年延續了2010年的樣貌,民進黨在投票率越高的地方支持率越高,而像是台北市,國民黨甚至發生了投票率高的地方支持度反而低的狀況,這很有可能代表了選民結構的變動,但在沒有做更近一步的分析前,這也只是臆測。
```{r 2014選舉概況}
taiwan_2010_to_2018 %>%
filter(city == "台北市") %>% #墨綠柯文哲
ggplot(aes(x = turnout_2014)) +
geom_point(aes(y = KMTrsp_2014), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2014), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = NPrsp_2014), color = "green", alpha = 0.3) +
geom_smooth(aes(y = NPrsp_2014), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2014年投票率與支持率(台北市)", x = "2014年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "新北市") %>%
ggplot(aes(x = turnout_2014)) +
geom_point(aes(y = KMTrsp_2014), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2014), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2014), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2014), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2014年投票率與支持率(新北市)", x = "2014年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "桃園市") %>%
ggplot(aes(x = turnout_2014)) +
geom_point(aes(y = KMTrsp_2014), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2014), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2014), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2014), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2014年投票率與支持率(桃園縣)", x = "2014年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台中市") %>%
ggplot(aes(x = turnout_2014)) +
geom_point(aes(y = KMTrsp_2014), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2014), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2014), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2014), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2014年投票率與支持率(台中市)", x = "2014年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台南市") %>%
ggplot(aes(x = turnout_2014)) +
geom_point(aes(y = KMTrsp_2014), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2014), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2014), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2014), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2014年投票率與支持率(台南市)", x = "2014年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>% # 藍營為楊秋興加上黃昭順
filter(city == "高雄市") %>%
ggplot(aes(x = turnout_2014)) +
geom_point(aes(y = KMTrsp_2014), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2014), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2014), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2014), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2014年投票率與支持率(高雄市)", x = "2014年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
```
##2010到2014年的變化(投票率與支持率)
以下幾張圖是10-14年投票率變化與支持率變化的圖。可以看到,台北市整體而言投票率其實變化不大,但是綠營(姑且把柯文哲算綠的)整體表現都優於2010年。新北市則是整體而言投票率都下降,而投票率下降這件事看起來對於國民黨陣營比較傷,不過傷得不夠所以朱立倫還是繼續當市長。至於台中台南高雄其實有一點類似的趨勢,那就是投票率降低的鄰里很多,但是民進黨在這些鄰里都有穩住或是獲得更多的支持。這或許可以說,藍營支持者們都不出來投票了,但要確定這點必須要再跑其他推論統計。
```{r 投票率與支持率變化 2010-2014}
taiwan_2010_to_2018 %>%
filter(city == "台北市") %>%
ggplot(aes(x = turnout_10_to_14)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = (NPrsp_2014 - DDPrsp_2010)), color = "green", alpha = 0.3) +
geom_smooth(aes(y = (NPrsp_2014 - DDPrsp_2010)), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2014年投票率變化與支持率變化(台北市)",
x = "10-14年投票率變化", y = "10-14年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "新北市") %>%
ggplot(aes(x = turnout_10_to_14)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2014年投票率變化與支持率變化(新北市)",
x = "10-14年投票率變化", y = "10-14年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "桃園市") %>%
ggplot(aes(x = turnout_10_to_14)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2014年投票率變化與支持率變化(桃園市)",
x = "10-14年投票率變化", y = "10-14年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台中市") %>%
ggplot(aes(x = turnout_10_to_14)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2014年投票率變化與支持率變化(台中市)",
x = "10-14年投票率變化", y = "10-14年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台南市") %>%
ggplot(aes(x = turnout_10_to_14)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_10_to_14), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2014年投票率變化與支持率變化(台南市)",
x = "10-14年投票率變化", y = "10-14年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "高雄市") %>%
ggplot(aes(x = turnout_10_to_14)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = (KMTrsp_10_to_14 - NPrsp_2010)), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = (KMTrsp_10_to_14 - NPrsp_2010)), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_10_to_14), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2014年投票率變化與支持率變化(高雄市)",
x = "10-14年投票率變化", y = "10-14年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
```
##2010到2014年的變化(兩黨支持率)
這組圖就可以較為完整的解釋了10-14年發生了什麼事,在台北市的各里,國民黨減少與民進黨增加的比率是接近的。新北市則是在各里兩黨支持度都減少,也就是說大家都不出來投票了。桃園則是兩黨選民都蜂擁而出投票,只是民進黨成功催出更多選票。台中、台南以及高雄都可以看到是國民黨掉的支持度比起民進黨增加的支持度還多,這也很有可能是因為失望的國民黨支持者通通窩在家裡看電視不去投票了。
```{r 兩黨支持率增減 2014}
taiwan_2010_to_2018 %>%
filter(city == "台北市") %>%
ggplot(aes(x = KMTrsp_10_to_14, y = (NPrsp_2014 - DDPrsp_2010))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2010-14兩黨支持率變化(台北市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "新北市") %>%
ggplot(aes(x = KMTrsp_10_to_14, y = (DDPrsp_10_to_14))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2010-14兩黨支持率變化(新北市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "桃園市") %>%
ggplot(aes(x = KMTrsp_10_to_14, y = (DDPrsp_10_to_14))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2010-14兩黨支持率變化(桃園市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台中市") %>%
ggplot(aes(x = KMTrsp_10_to_14, y = (DDPrsp_10_to_14))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2010-14兩黨支持率變化(台中市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台南市") %>%
ggplot(aes(x = KMTrsp_10_to_14, y = (DDPrsp_10_to_14))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2010-14兩黨支持率變化(台南市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "高雄市") %>%
ggplot(aes(x = (KMTrsp_10_to_14 - NPrsp_2010), y = (DDPrsp_10_to_14))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2010-14兩黨支持率變化(高雄市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
```
#2018年選舉
##2018選舉概況
比起前幾次選舉,這次比較有趣的變化是,國民黨的支持率在六都(除了台南、桃園之外),都有隨著投票率增加而增長。這有兩種可能的解釋。1.國民黨開始懂的如何催票了;2.2010年不需要催就會出來的鐵票倉不見了,現在都需要藉由提高投票率來增加支持率了。然後台南跟桃園則是不論投票率都表現得差不多,這對於國民黨來說是個警訊,代表
```{r 2018選舉概況}
taiwan_2010_to_2018 %>%
filter(city == "台北市") %>% #墨綠柯文哲
ggplot(aes(x = turnout_2018)) +
geom_point(aes(y = KMTrsp_2018), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2018), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = NPrsp_2018 + DDPrsp_2018), color = "green", alpha = 0.3) +
geom_smooth(aes(y = NPrsp_2018 + DDPrsp_2018), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2018年投票率與支持率(台北市)", x = "2018年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "新北市") %>%
ggplot(aes(x = turnout_2018)) +
geom_point(aes(y = KMTrsp_2018), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2018), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2018), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2018), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2018年投票率與支持率(新北市)", x = "2018年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "桃園市") %>%
ggplot(aes(x = turnout_2018)) +
geom_point(aes(y = KMTrsp_2018), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2018), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2018), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2018), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2018年投票率與支持率(桃園縣)", x = "2018年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台中市") %>%
ggplot(aes(x = turnout_2018)) +
geom_point(aes(y = KMTrsp_2018), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2018), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2018), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2018), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2018年投票率與支持率(台中市)", x = "2018年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台南市") %>%
ggplot(aes(x = turnout_2018)) +
geom_point(aes(y = KMTrsp_2018), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2018), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2018), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2018), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2018年投票率與支持率(台南市)", x = "2018年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>% # 藍營為楊秋興加上黃昭順
filter(city == "高雄市") %>%
ggplot(aes(x = turnout_2018)) +
geom_point(aes(y = KMTrsp_2018), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_2018), color = "blue", alpha = 0.4, method = "lm") +
geom_point(aes(y = DDPrsp_2018), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_2018), color = "green", alpha = 0.4, method = "lm") +
labs(title = "2018年投票率與支持率(高雄市)", x = "2018年投票率", y = "真實支持率") +
theme(text = element_text(family = "Heiti TC Light"))
```
##2014到2018年的變化(投票率與支持率)
到了大家最關心的2018年,台北市的狀況是,整體投票率下降,但兩邊陣營支持率變化不大。新北則是國民黨大獲全勝,投票率變高的地方都有所斬獲,相對的民進黨只是在投票率高的地方表現比較沒那麼差而已。桃園則是國民黨不斷地流失支持度,而民進黨則不論投票率,幾乎都有所斬獲。台中則是投票率變低,但國民黨支持度上升而民進黨下降,這大有可能是因為民進黨不出來投而國民黨都出來投了。而高雄則是投票率整體而言變高,國民黨支持度上升而民進黨下降,這代表了除了國民黨支持者蜂湧而出外,可能也有不少民進黨倒戈。
```{r 投票率與支持率變化 2014-2018}
taiwan_2010_to_2018 %>%
filter(city == "台北市") %>%
ggplot(aes(x = turnout_14_to_18)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = (NPrsp_14_to_18 + DDPrsp_2018)), color = "green", alpha = 0.3) +
geom_smooth(aes(y = (NPrsp_14_to_18 + DDPrsp_2018)), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2018年投票率變化與支持率變化(台北市)",
x = "14-18年投票率變化", y = "14-18年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "新北市") %>%
ggplot(aes(x = turnout_14_to_18)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = DDPrsp_14_to_18), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_14_to_18), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2018年投票率變化與支持率變化(新北市)",
x = "14-18年投票率變化", y = "14-18年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "桃園市") %>%
ggplot(aes(x = turnout_14_to_18)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = DDPrsp_14_to_18), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_14_to_18), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2018年投票率變化與支持率變化(桃園市)",
x = "14-18年投票率變化", y = "14-18年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台中市") %>%
ggplot(aes(x = turnout_14_to_18)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = DDPrsp_14_to_18), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_14_to_18), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2018年投票率變化與支持率變化(台中市)",
x = "14-18年投票率變化", y = "14-18年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "高雄市") %>%
ggplot(aes(x = turnout_14_to_18)) +
geom_hline(yintercept = 0, alpha = 0.5) + geom_vline(xintercept = 0, alpha = 0.5) +
expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3) +
geom_smooth(aes(y = KMTrsp_14_to_18), color = "blue", alpha = 0.3, method = "lm") +
geom_point(aes(y = DDPrsp_14_to_18), color = "green", alpha = 0.3) +
geom_smooth(aes(y = DDPrsp_14_to_18), color = "green", alpha = 0.3, method = "lm") +
labs(title = "2014年投票率變化與支持率變化(高雄市)",
x = "10-14年投票率變化", y = "10-14年真實支持率變化") +
theme(text = element_text(family = "Heiti TC Light"))
```
##2014到2018年的變化(兩黨支持率)
```{r 兩黨支持率增減 2018}
taiwan_2010_to_2018 %>%
filter(city == "台北市") %>%
ggplot(aes(x = KMTrsp_14_to_18, y = (NPrsp_14_to_18 + DDPrsp_2018))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2014-18兩黨支持率變化(台北市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "新北市") %>%
ggplot(aes(x = KMTrsp_14_to_18, y = (DDPrsp_14_to_18))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2014-18兩黨支持率變化(新北市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "桃園市") %>%
ggplot(aes(x = KMTrsp_14_to_18, y = (DDPrsp_14_to_18))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2014-18兩黨支持率變化(桃園市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台中市") %>%
ggplot(aes(x = KMTrsp_14_to_18, y = (DDPrsp_14_to_18))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2014-18兩黨支持率變化(台中市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "高雄市") %>%
ggplot(aes(x = (KMTrsp_14_to_18), y = (DDPrsp_14_to_18))) +
geom_hline(yintercept = 0, alpha = 0.3) + geom_vline(xintercept = 0, alpha = 0.3) +
geom_abline(slope = -1, alpha = 0.3) + expand_limits( x = c(-0.3,0.3), y = c(-0.3, 0.3)) +
geom_point(alpha = 0.4, color = "purple") +
labs(title = "2014-18兩黨支持率變化(高雄市)", x = "國民黨支持度變化", y = "民進黨支持度變化") +
theme(text = element_text(family = "Heiti TC Light"))
```
#2010到2018年的消長
以下幾個圖是總結我推論的圖,橫軸是10-14年支持度的變化而縱軸則是14-18年支持度的變化。如果資料點大多位於第一象限,代表著這區八年來是越來越偏向某個政黨,如果是在第二象限,則代表四年前選輸的票數回來了,第三象限則是這個黨在這區節節敗退,第四象限則是18年這次選舉把14年贏的吐回去了。
我們可以發現,台北市的格局在14年就定了,柯文哲增長的票並沒有在18年有太多流失,台北人就愛白色力量這一味。新北則是在14年兩黨支持率都下降(大家都不出來投),但國民黨成功拉回支持度。桃園則是民進黨持續增長、國民黨則在18年出現衰退。台中跟高雄就是民進黨把在14年贏的吐回去,國民黨把輸的贏回來,其中又以高雄的變化比起台中大。
```{r 10-14支持率改變與14-18年支持率改變}
taiwan_2010_to_2018 %>%
filter(city == "台北市") %>%
ggplot() +
geom_point(aes(x = KMTrsp_10_to_14, y = KMTrsp_14_to_18), color = "blue", alpha = 0.2) +
geom_smooth(aes(x = KMTrsp_10_to_14, y = KMTrsp_14_to_18), color = "blue", method = "lm", alpha = 0.2) +
geom_point(aes(x = (NPrsp_2014 - DDPrsp_2010), y = (NPrsp_14_to_18 + DDPrsp_2018)),
color = "green", alpha = 0.2) +
geom_smooth(aes(x = (NPrsp_2014 - DDPrsp_2010), y = (NPrsp_14_to_18 + DDPrsp_2018)),
color = "green", method = "lm", alpha = 0.2) +
labs(title = "台北三屆選舉支持率變化", x = "10-14年支持率變化", y = "14-18年支持率變化") +
expand_limits(x = c(-0.3, 0.3), y = c(-0.3, 0.3)) + geom_hline(yintercept = 0, alpha = 0.3) +
geom_vline(xintercept = 0, alpha = 0.3) +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "新北市") %>%
ggplot() +
geom_point(aes(x = KMTrsp_10_to_14, y = KMTrsp_14_to_18), color = "blue", alpha = 0.2) +
geom_smooth(aes(x = KMTrsp_10_to_14, y = KMTrsp_14_to_18), color = "blue", method = "lm", alpha = 0.2) +
geom_point(aes(x = DDPrsp_10_to_14, y = DDPrsp_14_to_18), color = "green", alpha = 0.2) +
geom_smooth(aes(x = DDPrsp_10_to_14, y = DDPrsp_14_to_18), color = "green", method = "lm", alpha = 0.2) +
labs(title = "新北三屆選舉支持率變化", x = "10-14年支持率變化", y = "14-18年支持率變化") +
expand_limits(x = c(-0.3, 0.3), y = c(-0.3, 0.3)) + geom_hline(yintercept = 0, alpha = 0.3) +
geom_vline(xintercept = 0, alpha = 0.3) +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "桃園市") %>%
ggplot() +
geom_point(aes(x = KMTrsp_10_to_14, y = KMTrsp_14_to_18), color = "blue", alpha = 0.2) +
geom_smooth(aes(x = KMTrsp_10_to_14, y = KMTrsp_14_to_18), color = "blue", method = "lm", alpha = 0.2) +
geom_point(aes(x = DDPrsp_10_to_14, y = DDPrsp_14_to_18), color = "green", alpha = 0.2) +
geom_smooth(aes(x = DDPrsp_10_to_14, y = DDPrsp_14_to_18), color = "green", method = "lm", alpha = 0.2) +
labs(title = "桃園三屆選舉支持率變化", x = "10-14年支持率變化", y = "14-18年支持率變化") +
expand_limits(x = c(-0.3, 0.3), y = c(-0.3, 0.3)) + geom_hline(yintercept = 0, alpha = 0.3) +
geom_vline(xintercept = 0, alpha = 0.3) +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "台中市") %>%
ggplot() +
geom_point(aes(x = KMTrsp_10_to_14, y = KMTrsp_14_to_18), color = "blue", alpha = 0.2) +
geom_smooth(aes(x = KMTrsp_10_to_14, y = KMTrsp_14_to_18), color = "blue", method = "lm", alpha = 0.2) +
geom_point(aes(x = DDPrsp_10_to_14, y = DDPrsp_14_to_18), color = "green", alpha = 0.2) +
geom_smooth(aes(x = DDPrsp_10_to_14, y = DDPrsp_14_to_18), color = "green", method = "lm", alpha = 0.2) +
labs(title = "台中三屆選舉支持率變化", x = "10-14年支持率變化", y = "14-18年支持率變化") +
expand_limits(x = c(-0.3, 0.3), y = c(-0.3, 0.3)) + geom_hline(yintercept = 0, alpha = 0.3) +
geom_vline(xintercept = 0, alpha = 0.3) +
theme(text = element_text(family = "Heiti TC Light"))
taiwan_2010_to_2018 %>%
filter(city == "高雄市") %>%
ggplot() +
geom_point(aes(x = (KMTrsp_10_to_14 - NPrsp_2010), y = KMTrsp_14_to_18), color = "blue", alpha = 0.2) +
geom_smooth(aes(x = (KMTrsp_10_to_14 - NPrsp_2010), y = KMTrsp_14_to_18), color = "blue",
method = "lm", alpha = 0.2) +
geom_point(aes(x = DDPrate_10_to_14, y = DDPrate_14_to_18), color = "green", alpha = 0.2) +
geom_smooth(aes(x = DDPrate_10_to_14, y = DDPrate_14_to_18), color = "green", method = "lm", alpha = 0.2) +
labs(title = "高雄三屆選舉支持率變化", x = "10-14年支持率變化", y = "14-18年支持率變化") +
expand_limits(x = c(-0.3, 0.3), y = c(-0.3, 0.3)) + geom_hline(yintercept = 0, alpha = 0.3) +