Skip to content

Commit

Permalink
polling places
Browse files Browse the repository at this point in the history
  • Loading branch information
hardin47 committed Jan 24, 2024
1 parent eb3e3ee commit 91d2ad9
Show file tree
Hide file tree
Showing 23 changed files with 465,366 additions and 1 deletion.
6 changes: 6 additions & 0 deletions 2023-12-12/holidaymovies.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ <h2 class="anchored" data-anchor-id="common-holday-words-and-phrases">Common hol
<p><img src="holidaymovies_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid" alt="An upset plot with genre combinations on the x-axis and frequency on the y-axis. Comedy is the most popular genre, closely followed by Comedy-Romance pair of genres." width="672"></p>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="fu">praise</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] "You are fabulous!"</code></pre>
</div>
</div>
</section>

</main>
Expand Down
3 changes: 3 additions & 0 deletions 2023-12-12/holidaymovies.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ genres |>



```{r}
praise()
```



Expand Down
Binary file added 2024-01-16/pic1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2024-01-16/pic2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
462 changes: 462 additions & 0 deletions 2024-01-16/polling.html

Large diffs are not rendered by default.

129 changes: 129 additions & 0 deletions 2024-01-16/polling.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
title: "Polling Places"
author: "Jo Hardin"
date: "01/16/2024"
format: html
execute:
warning: false
message: false
---


```{r}
library(tidyverse) # ggplot, lubridate, dplyr, stringr, readr...
library(tidytext)
library(praise)
library(paletteer)
```


## The Data

The [dataset](https://github.com/PublicI/us-polling-places) comes from [The Center for Public Integrity](https://publicintegrity.org/). Each row represents a US polling place (location to vote in an election) across many elections from 2012 to 2020.

```{r}
polling <- read_csv("polling_places.csv") |>
mutate(year = year(election_date),
name = tolower(name),
address = tolower(address))
```


## Where did people poll?


```{r}
polling <- polling |>
mutate(location_type = case_when(
grepl("church", name) | grepl("church", address) ~ "church",
grepl("community", name) | grepl("community", address) ~ "community center",
grepl("comm", name) | grepl("comm", address) ~ "community center",
grepl("rec center", name) | grepl("rec center", address) ~ "community center",
grepl("recreation", name) | grepl("recreation", address) ~ "community center",
grepl("activity", name) | grepl("activity", address) ~ "community center",
grepl("fire", name) | grepl("fire", address)~ "fire dept",
grepl("vfd", name) | grepl("vfd", address) ~ "fire dept",
grepl("baptist", name) | grepl("baptist", address) ~ "church",
grepl("methodist", name) | grepl("methodist", address) ~ "church",
grepl("unitarian", name) | grepl("unitarian", address) ~ "church",
grepl("chapel", name) | grepl("chapel", address) ~ "church",
grepl("parish", name) | grepl("parish", address) ~ "church",
grepl("god", name) | grepl("god", address) ~ "church",
grepl("christian", name) | grepl("christian", address) ~ "church",
grepl("synagogue", name) | grepl("synagogue", address) ~ "church",
grepl("friends meet", name) | grepl("friends meet", address) ~ "church",
grepl("holy", name) | grepl("holy", address) ~ "church",
grepl("elementary", name) | grepl("elementary", address) ~ "elementary school",
grepl("kindergarten", name) | grepl("kindergarten", address) ~ "elementary school",
grepl("elem sch", name) | grepl("elem sch", address) ~ "elementary school",
grepl("middle school", name) | grepl("middle school", address) ~ "post-elementary school",
grepl("junior high", name) | grepl("junior high", address) ~ "post-elementary school",
grepl("sr high", name) | grepl("sr high", address) ~ "post-elementary school",
grepl("sr high", name) | grepl("sr high", address) ~ "post-elementary school",
grepl("school", name) | grepl("school", address) ~ "other school",
grepl("college", name) | grepl("college", address) ~ "other school",
grepl("academy", name) | grepl("academy", address) ~ "other school",
grepl("civic center", name) | grepl("civic center", address) ~ "city center",
grepl("chamber of commerce", name) | grepl("chamber of commerce", address) ~ "city center",
grepl("courthouse", name) | grepl("courthoue", address) ~ "city center",
grepl("cultural center", name) | grepl("cultural center", address) ~ "community center",
grepl("town hall", name) | grepl("town hall", address) ~ "city center",
grepl("library", name) | grepl("library", address) ~ "library",
grepl("veteran", name) | grepl("veteran", address) ~ "hall",
grepl("vfw", name) | grepl("vfw", address) ~ "hall",
grepl("legion", name) | grepl("legion", address) ~ "hall",
grepl("masonic", name) | grepl("masonic", address) ~ "hall",
grepl("elk", name) | grepl("elk", address) ~ "hall",
grepl("hall", name) | grepl("hall", address) ~ "hall",
grepl("senior", name) | grepl("senior", address) ~ "senior",
grepl("elderly", name) | grepl("elderly", address) ~ "senior",
grepl("vote center", name) | grepl("vote center", address) ~ "vote center",
TRUE ~ "other"
))
```


```{r}
pal <- c("#000000","#004949","#009292","#ff6db6","#ffb6db",
"#490092","#006ddb","#b66dff","#6db6ff","#b6dbff",
"#920000","#924900","#db6d00","#24ff24","#ffff6d")
polling |>
ggplot(aes(fill = location_type, x = year)) +
geom_bar() +
scale_x_continuous(breaks=seq(2012,2020,4)) +
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
labs(x = "", fill = "location type") +
scale_x_continuous(breaks=seq(2012,2020,2)) +
scale_fill_manual(values = pal) +
coord_flip()
```

```{r}
library(geofacet)
polling |>
ggplot(aes(fill = location_type, x = year)) +
geom_bar() +
scale_x_continuous(breaks=seq(2012,2020,4)) +
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1)) +
labs(x = "", fill = "location type") +
scale_x_continuous(breaks=seq(2012,2020,4)) +
scale_y_continuous(breaks=seq(0,15000,10000)) +
scale_fill_manual(values = pal) +
coord_flip() +
facet_geo(~state)
```




```{r}
praise()
```


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.
Loading

0 comments on commit 91d2ad9

Please sign in to comment.