This announcement from Jay Lee, Matthew Yancheff, and Mia Leung, three Reed students who were in the Data and Election Sciences course that I taught along with Prof. Andrew Bray this spring. They have released the results of their work to CRAN.
Thanks to Rob Richie and Theo Landsman of FairVote for helping push this forward.
Hello,
Just wanted to let you know that the first version of our RCV package is now submitted to CRAN, the R package archive! Going forward we’ll be updating this work, so if you have any comments or bug fixes please feel free to submit a pull request or issue to our GitHub repository, or just email us directly.
I’ve included a few lines of code at the bottom of this email to install the package locally and go through an example election (San Francisco Board of Supervisors, District 7). You’ll need at least version 3.3 of R installed to run these. If you don’t have this installed and don’t want to, some of the examples are available at our GitHub repo (scroll down to the README).
Again, thank you so much for your interest in our work and any help you’ve given us in regards to this project. We look forward to hearing any comments or critiques you might have on your experience using our package.
Thank you,
Jay Lee
Reed College
install.packages("rcv")
library(rcv)
sf_cleaned <- clean_ballot(ballot = sf_bos_ballot, b_header = T, lookup = sf_bos_lookup, l_header = T, format = "WinEDS")
results7 <- rcv_tally(sf_cleaned, "Board of Supervisors, District 7")
The results table for this election is stored in the `results7` object. It can be printed in the console with the first line of code provided below, or viewed in the RStudio window with the second line:
results7
View(results7)
We also have a functionality for producing an interactive type of flowchart called a Sankey diagram. This is done with the networkD3 package, which you must install separately to produce the visualization. The code for that is again provided here, but if you don’t want to install it we have an example on our GitHub repo.
install.packages("networkD3")
library(networkD3)
d3_7 <- rcv::make_d3list(results = results7)
networkD3::sankeyNetwork(Links = d3_7$values, Nodes = d3_7$names, Source = "source", Target = "target", Value = "value", NodeID = "candidate", units = "voters", fontSize = 12, nodeWidth = 20)
Share this page