@kjhealy
R Code to scrape constituency-level results from the BBC Election results pages and make some figures and maps.
Related post: Who Came Second in the UK Elections?
Thanks to Martin Chorley's UK-GeoJSON project for the TopoJSON map data.
Mapping UK Election Results.
@kjhealy
R Code to scrape constituency-level results from the BBC Election results pages and make some figures and maps.
Related post: Who Came Second in the UK Elections?
Thanks to Martin Chorley's UK-GeoJSON project for the TopoJSON map data.
I did face some road blocks but was able to bypass them by including some libraries. But when i am in the step
all.results.list[[name]] <- get.constituency.results(constituency), it fails each time.
Error: could not find function "get.constituency.results". I am not very experienced in R. For verifying it, i took it out of the For Loop and hardcoded the index to [1] or [2] to generate Aberavon.rda or Aberconwy.rda. But for both steps i get the same result.
I understand that "constituency" is holding the JSON format from read_html. But i am clueless further.
Other than that code runs perfectly for me. I do get an error that I don't have a perl interpreter installed but since we never load an xls file I dont think that matters unless of course that is related to the credit() function call.
@kjhealy I'm curious, what was your thinking behind the '15 candidates standing' threshold for defining the main parties?
### parties by N candidates
main.parties <- data %>% group_by(Party) %>% tally() %>% arrange(desc(n)) %>%
filter(n>14) %>% data.frame(.)
I'm trying to decide if this level of aggregation makes sense for a graphic I'm working on. Thanks for the insight!
@kjhealy many thanks for sharing the dataset and the script. When I attempt to run the first two sections in RStudio I encounter this error:
Error in eval(expr, envir, enclos) : could not find function "read_html"
Hi,
I'm very new to R and to Github.
I installed the packages I was missing and ran the code only to find that I was still missing 'gdata' (called on line 154) and 'mapproj' so you may want to add these to the library calls at the top.
Also the code seemed to fail for me as it was trying to write to the 'figures' subdirectory but that directory didn't exist. Adding the directory manually fixed this.
Still working through some other issues.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.