Browse Source

Daily graph

Petra Lamborn 1 year ago
parent
commit
443b8b5d47
2 changed files with 35 additions and 0 deletions
  1. 19
    0
      2020-advance-vote-data.csv
  2. 16
    0
      votingpatterns.R

+ 19
- 0
2020-advance-vote-data.csv View File

@@ -0,0 +1,19 @@
1
+Date,2020 General Election,2017 General Election,2014 General Election
2
+2020-09-30,,,12031
3
+2020-10-01,,,14585
4
+2020-10-02,,,16747
5
+2020-10-03,92706,,6134
6
+2020-10-04,67423,0,0
7
+2020-10-05,107299,39570,22234
8
+2020-10-06,103579,48238,22846
9
+2020-10-07,107853,66084,23950
10
+2020-10-08,,72932,29033
11
+2020-10-09,,82422,31753
12
+2020-10-10,,89480,46200
13
+2020-10-11,,45306,0
14
+2020-10-12,,105228,60966
15
+2020-10-13,,123307,62595
16
+2020-10-14,,133813,86021
17
+2020-10-15,,180887,122017
18
+2020-10-16,,253473,160467
19
+Totals,478860,1240740,717579

+ 16
- 0
votingpatterns.R View File

@@ -107,3 +107,19 @@ pvplot <- ggplot(filter(partylev, Party %in% names(partycolours)),
107 107
                        expand=c(0,0), limits = c(0, 0.5), labels = scales::percent) +
108 108
     labs(title = "Party vote trajectories")
109 109
 pvplot
110
+
111
+daily <- read.csv("2020-advance-vote-data.csv", stringsAsFactors = FALSE) %>%
112
+    filter(Date != "Totals") %>% mutate(Date = as.Date(Date)) %>%
113
+    pivot_longer(cols = X2020.General.Election:X2014.General.Election, names_to = "Year", names_pattern = "^X([0-9]{4}).*$", values_to = "Votes") %>%
114
+    mutate(Votes = ifelse(is.na(Votes), 0, Votes))
115
+
116
+dailyplot <- ggplot(daily, aes(x = Date, y = Votes, fill = Year)) +
117
+    geom_col(position="dodge") +
118
+    scale_x_date("2020 election-equivalent date",
119
+                 date_breaks = "1 day", date_labels = "%a %b %e",
120
+                 expand = c(0,0)) +
121
+    scale_fill_brewer("Election year", palette = "Set2") +
122
+    scale_y_continuous("Advance votes", labels = scales::comma, expand = c(0,0)) +
123
+    labs(title = "Daily Advance Votes", subtitle = "Last updated 8 October 2020") +
124
+    theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))
125
+dailyplot