JohnCRuf / alderman_machine

This is the repository for a research project investigating clientelistic politics in Chicago
3 stars 2 forks source link

Bernie Stone case study #29

Closed JohnCRuf closed 1 year ago

JohnCRuf commented 1 year ago

This PR is downstream of PR #26. This PR also addresses issue #19.

It adds a new task that creates case-study maps of Bernie Stone's vote counts and total menu contributions. We find that quantitatively, the rumors are true. Bernie stone did not seem to spend much on the west side of the ward, where he loses most of the elections.

JohnCRuf commented 1 year ago

Commit outputs, write up a logbook entry with findings.

JohnCRuf commented 1 year ago

@tmalthouse try to give this a review over the weekend if possible. Just quickly go through it to make sure the readme's are accurate and the code runs.

tmalthouse commented 1 year ago

Readme files look good—I'm having some trouble getting the code to run, but I'm fairly sure that's just a dependency problem in my R installation.

JohnCRuf commented 1 year ago

Oof, I may have forgotten to add the new packages to setup_environment. Run that and let me know of any packages that I forgot.

Readme files look good—I'm having some trouble getting the code to run, but I'm fairly sure that's just a dependency problem in my R installation.

tmalthouse commented 1 year ago

nvm—just figured it out. My docker install was fubar. Reinstalling now—hoping this'll fix it.

tmalthouse commented 1 year ago

Docker is fixed, I am now erroring out in data_scrape_elections. Attached is the output of that task's makefile—it seems that I'm getting an empty response. Could you try rerunning this task to see whether the problem's on my end (maybe the ARM-AMD64 mismatch?) or on chicagoelections.gov?

(base) code git:1a758f8 ❯ make                                                                                                                    ✭
Running elections_webscraping.R via R, waiting...
── Attaching core tidyverse packages ──────────────────────────────────────────────────────────────────────────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.2     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors

Attaching package: ‘rvest’

The following object is masked from ‘package:readr’:

    guess_encoding

586b8dda3fc4
Using default tag: latest
latest: Pulling from selenium/standalone-chrome
Digest: sha256:081ff2eb6434de308276c4476c35caaa60bc17877509a9c8dcb51e0061efb9a4
Status: Image is up to date for selenium/standalone-chrome:latest
docker.io/selenium/standalone-chrome:latest
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
dc6b263963d6545fb43dd1f0bef9ff739c90e5ee6388318373dc83179714e2e1
[1] "Connecting to remote server"
Error in checkError(res) : 
  Undefined error in httr call. httr output: Empty reply from server
Calls: <Anonymous> -> queryRD -> checkError
Execution halted
make: *** [../output/elections.csv] Error 1
JohnCRuf commented 1 year ago

Agh, the data scraping code seems to go stale every few months. Let me make a quick PR that commits the election data, and add an issue that this is stale.

JohnCRuf commented 1 year ago

Ok I think I figured out the issue: https://stackoverflow.com/questions/76294801/remdropen-hangs-when-using-rselenium-and-docker

I accidentally deleted my election data (WHOOPS) but I think this fixes the docker hang on line 35 when I open the selenium session. I'll remake it, add the code to a new PR, and submit today.