Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjbrailey committed Mar 31, 2020
1 parent 01c4667 commit b0f3173
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 12 deletions.
28 changes: 23 additions & 5 deletions content/posts/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ <h1>The Function</h1>
<ol start="2" style="list-style-type: decimal">
<li>So now we have our data ready. There are a few columns that can probably get removed once we have calculated electoral proximity, but you never know when they might come in handy.</li>
</ol>
<p>To elucidate:
<span class="math inline">\(\textit{leg_elect_year}\)</span> = <span class="math inline">\(L_t\)</span>
<span class="math inline">\(\textit{pres_elect_year_fill}\)</span> = <span class="math inline">\(P_{t-1}\)</span>
<span class="math inline">\(\textit{next_election}\)</span> = <span class="math inline">\(P_{t+1}\)</span></p>
<p>To elucidate:</p>
<p><span class="math inline">\(\textit{leg_elect_year}\)</span> = <span class="math inline">\(L_t\)</span></p>
<p><span class="math inline">\(\textit{pres_elect_year_fill}\)</span> = <span class="math inline">\(P_{t-1}\)</span></p>
<p><span class="math inline">\(\textit{next_election}\)</span> = <span class="math inline">\(P_{t+1}\)</span></p>
<pre class="r"><code>burkina_faso &lt;- burkina_faso %&gt;%

#&#39; We can now, in one fell swoop, calculate Cox&#39;s electoral proximity.
Expand All @@ -81,5 +81,23 @@ <h1>The Function</h1>
leg_elect_year - pres_elect_year_fill) /
(next_election - pres_elect_year_fill) - (1/2)
), NA),
cox_prox = ifelse(is.nan(cox_prox), 1, cox_prox))</code></pre>
cox_prox = ifelse(is.nan(cox_prox), 1, cox_prox)) %&gt;%

#&#39; Fill out the variable.
tidyr::fill(cox_prox)</code></pre>
</div>
<div id="burkina-fasos-electoral-proximity" class="section level1">
<h1>Burkina Faso’s Electoral Proximity</h1>
<p>Let’s plot how electoral proximity changes over time in Burkina Faso.</p>
<pre class="r"><code>ggplot(burkina_faso, aes(x = year)) +
geom_line(aes(y = cox_prox), size = 2, color = &quot;purple&quot;) +
geom_vline(aes(xintercept = ifelse(leg_elect_dum == 1, year, NA)), linetype = &quot;dotted&quot;) +
labs(title = paste0(&quot;Electoral Proximity in &quot;, unique(burkina_faso$country_name)),
x = &quot;Year&quot;,
y = &quot;Electoral Proximity (Cox, 1997)&quot;) +
theme_classic()
## Warning: Removed 18 rows containing missing values (geom_path).
## Warning: Removed 51 rows containing missing values (geom_vline).</code></pre>
<p><img src="/posts/test_files/figure-html/unnamed-chunk-4-1.png" width="672" />
Interesting! Following independence, BK had concurrent elections which became progressively less concurrent until 2015, when they aligned once again. I’m going to plot a few more countries and see if I find any more intresting patterns.</p>
</div>
23 changes: 21 additions & 2 deletions public/posts/test.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ tags: ["R", "electoral proximity", "making votes count"]
knitr::opts_chunk$set(collapse = TRUE)
library(magrittr)
library(ggplot2)
burkina_faso <- rio::import("C:/Users/tbrai/Dropbox/Constitutions Project/Data/Election Data/Cleaned Data/cp_af_full.csv") %>%
dplyr::select(country_name, year,
leg_elect_dum, leg_elect_year,
Expand Down Expand Up @@ -71,9 +72,13 @@ burkina_faso <- burkina_faso %>%
2. So now we have our data ready. There are a few columns that can probably get removed once we have calculated electoral proximity, but you never know when they might come in handy.

To elucidate:

$\textit{leg_elect_year}$ = $L_t$

$\textit{pres_elect_year_fill}$ = $P_{t-1}$

$\textit{next_election}$ = $P_{t+1}$

```{r}
burkina_faso <- burkina_faso %>%
Expand All @@ -84,11 +89,25 @@ burkina_faso <- burkina_faso %>%
leg_elect_year - pres_elect_year_fill) /
(next_election - pres_elect_year_fill) - (1/2)
), NA),
cox_prox = ifelse(is.nan(cox_prox), 1, cox_prox))
cox_prox = ifelse(is.nan(cox_prox), 1, cox_prox)) %>%
#' Fill out the variable.
tidyr::fill(cox_prox)
```

# Burkina Faso's Electoral Proximity

Let's plot how electoral proximity changes over time in Burkina Faso.
```{r}
ggplot(burkina_faso, aes(x = year)) +
geom_line(aes(y = cox_prox), size = 2, color = "purple") +
geom_vline(aes(xintercept = ifelse(leg_elect_dum == 1, year, NA)), linetype = "dotted") +
labs(title = paste0("Electoral Proximity in ", unique(burkina_faso$country_name)),
x = "Year",
y = "Electoral Proximity (Cox, 1997)") +
theme_classic()
```
Interesting! Following independence, BK had concurrent elections which became progressively less concurrent until 2015, when they aligned once again. I'm going to plot a few more countries and see if I find any more intresting patterns.



Expand Down
28 changes: 23 additions & 5 deletions public/posts/test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ <h1>The Function</h1>
<ol start="2" style="list-style-type: decimal">
<li>So now we have our data ready. There are a few columns that can probably get removed once we have calculated electoral proximity, but you never know when they might come in handy.</li>
</ol>
<p>To elucidate:
<span class="math inline">\(\textit{leg_elect_year}\)</span> = <span class="math inline">\(L_t\)</span>
<span class="math inline">\(\textit{pres_elect_year_fill}\)</span> = <span class="math inline">\(P_{t-1}\)</span>
<span class="math inline">\(\textit{next_election}\)</span> = <span class="math inline">\(P_{t+1}\)</span></p>
<p>To elucidate:</p>
<p><span class="math inline">\(\textit{leg_elect_year}\)</span> = <span class="math inline">\(L_t\)</span></p>
<p><span class="math inline">\(\textit{pres_elect_year_fill}\)</span> = <span class="math inline">\(P_{t-1}\)</span></p>
<p><span class="math inline">\(\textit{next_election}\)</span> = <span class="math inline">\(P_{t+1}\)</span></p>
<pre class="r"><code>burkina_faso &lt;- burkina_faso %&gt;%

#&#39; We can now, in one fell swoop, calculate Cox&#39;s electoral proximity.
Expand All @@ -259,7 +259,25 @@ <h1>The Function</h1>
leg_elect_year - pres_elect_year_fill) /
(next_election - pres_elect_year_fill) - (1/2)
), NA),
cox_prox = ifelse(is.nan(cox_prox), 1, cox_prox))</code></pre>
cox_prox = ifelse(is.nan(cox_prox), 1, cox_prox)) %&gt;%

#&#39; Fill out the variable.
tidyr::fill(cox_prox)</code></pre>
</div>
<div id="burkina-fasos-electoral-proximity" class="section level1">
<h1>Burkina Faso’s Electoral Proximity</h1>
<p>Let’s plot how electoral proximity changes over time in Burkina Faso.</p>
<pre class="r"><code>ggplot(burkina_faso, aes(x = year)) +
geom_line(aes(y = cox_prox), size = 2, color = &quot;purple&quot;) +
geom_vline(aes(xintercept = ifelse(leg_elect_dum == 1, year, NA)), linetype = &quot;dotted&quot;) +
labs(title = paste0(&quot;Electoral Proximity in &quot;, unique(burkina_faso$country_name)),
x = &quot;Year&quot;,
y = &quot;Electoral Proximity (Cox, 1997)&quot;) +
theme_classic()
## Warning: Removed 18 rows containing missing values (geom_path).
## Warning: Removed 51 rows containing missing values (geom_vline).</code></pre>
<p><img src="/posts/test_files/figure-html/unnamed-chunk-4-1.png" width="672" />
Interesting! Following independence, BK had concurrent elections which became progressively less concurrent until 2015, when they aligned once again. I’m going to plot a few more countries and see if I find any more intresting patterns.</p>
</div>

</div>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b0f3173

Please sign in to comment.