Skip to content
An R data package containing general election results for New Mexico (2014, 2016 & 2018)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data-raw
data
man
nmelection_tables
.Rbuildignore
.gitignore
DESCRIPTION
NAMESPACE
README.Rmd
README.md
nmelectiondatr.Rproj

README.md

nmelectiondatr

An R data package for Election Data in New Mexico

The package includes general election results for the state of New Mexico (2014, 2016 & 2018), including returns for federal, legislative, and statewide offices. Election returns are made available at the precinct, county, and state legislative levels.

Data included in the package have been collated from excel files made available by the New Mexico Secretary of State. Anyone who has dealt with NM SOS data knows they are challenging to work with. Here, we make these data available in simple, aggregated tables that enable more straightforward analyses.

Tables can be accessed via the R package described here, as a collection of CSVs, or as individual tabs in a single Excel file. A full code-through of the scraping & summary processes is available here. Code includes functions for gathering election returns that can be used for future statewide/state legislative/federal elections in New Mexico.

Installation

library(devtools)
devtools::install_github("jaytimm/nmelectiondatr")
library(nmelectiondatr)

Usage

Election returns

Election results are summarized in four data tables; their contents are summarized below:

Table Contents
nmel_results_summary An overview of election winners
nmel_results_precinct Election returns by precinct
nmel_results_district Election returns by district
nmel_results_county Election returns by county

A summary of election results:

nmelectiondatr::nmel_results_summary
## # A tibble: 449 x 8
##    Year  Type         Type_Sub Candidate        Party Votes Percent Winner
##    <chr> <chr>        <chr>    <chr>            <chr> <dbl>   <dbl> <chr> 
##  1 2018  State Repre~ 1        RODNEY D MONTOYA REP   8512.   1.00  Winner
##  2 2018  State Repre~ 10       G ANDRES ROMERO  DEM   4927.   1.00  Winner
##  3 2018  State Repre~ 11       JAVIER I MARTIN~ DEM   9875.   1.00  Winner
##  4 2018  State Repre~ 12       PATRICIO R RUIL~ DEM   4326.   1.00  Winner
##  5 2018  State Repre~ 13       PATRICIA A ROYB~ DEM   4749.   1.00  Winner
##  6 2018  State Repre~ 14       MIGUEL P GARCIA  DEM   5370.   1.00  Winner
##  7 2018  State Repre~ 15       DAYAN M HOCHMAN  DEM   6583.   0.521 Winner
##  8 2018  State Repre~ 15       BRAD WINTER      REP   6043.   0.479 ""    
##  9 2018  State Repre~ 16       ANTONIO 'MOE' M~ DEM   7694.   1.00  Winner
## 10 2018  State Repre~ 17       DEBORAH A ARMST~ DEM   7027.   0.650 Winner
## # ... with 439 more rows

Election returns by precinct:

nmelectiondatr::nmel_results_precinct
## # A tibble: 107,965 x 8
##    Year  Type     Type_Sub County_Name Precinct_Num Candidate  Votes Party
##    <chr> <chr>    <chr>    <chr>              <dbl> <chr>      <dbl> <chr>
##  1 2018  State R~ 1        San Juan             28. RODNEY D ~  284. REP  
##  2 2018  State R~ 1        San Juan             29. RODNEY D ~  197. REP  
##  3 2018  State R~ 1        San Juan             31. RODNEY D ~  815. REP  
##  4 2018  State R~ 1        San Juan             32. RODNEY D ~  129. REP  
##  5 2018  State R~ 1        San Juan             33. RODNEY D ~  283. REP  
##  6 2018  State R~ 1        San Juan             34. RODNEY D ~  241. REP  
##  7 2018  State R~ 1        San Juan             39. RODNEY D ~  717. REP  
##  8 2018  State R~ 1        San Juan             41. RODNEY D ~  627. REP  
##  9 2018  State R~ 1        San Juan             42. RODNEY D ~  555. REP  
## 10 2018  State R~ 1        San Juan             44. RODNEY D ~  621. REP  
## # ... with 107,955 more rows

Election returns by county, which additionally include early and absentee voting counts:

nmelectiondatr::nmel_results_county
## # A tibble: 8,024 x 7
##    Year  Type                  NAME       Candidate  Votes Party Cast 
##    <chr> <chr>                 <chr>      <chr>      <dbl> <chr> <chr>
##  1 2018  United States Senator Bernalillo MICK RICH 61932. REP   Total
##  2 2018  United States Senator Catron     MICK RICH  1075. REP   Total
##  3 2018  United States Senator Chaves     MICK RICH  8727. REP   Total
##  4 2018  United States Senator Cibola     MICK RICH  1842. REP   Total
##  5 2018  United States Senator Colfax     MICK RICH  1615. REP   Total
##  6 2018  United States Senator Curry      MICK RICH  5896. REP   Total
##  7 2018  United States Senator De Baca    MICK RICH   342. REP   Total
##  8 2018  United States Senator Dona Ana   MICK RICH 18101. REP   Total
##  9 2018  United States Senator Eddy       MICK RICH  8826. REP   Total
## 10 2018  United States Senator Grant      MICK RICH  3598. REP   Total
## # ... with 8,014 more rows

Election returns by state legislative districts:

nmelectiondatr::nmel_results_district
## # A tibble: 1,476 x 7
##    Year  Type                 NAME  Candidate          Votes Party Cast   
##    <chr> <chr>                <chr> <chr>              <dbl> <chr> <chr>  
##  1 2018  State Representative 1     RODNEY D MONTOYA   8512. REP   Total  
##  2 2018  State Representative 1     RODNEY D MONTOYA    521. REP   Absent~
##  3 2018  State Representative 1     RODNEY D MONTOYA   4651. REP   Early  
##  4 2018  State Representative 1     RODNEY D MONTOYA   3340. REP   Electi~
##  5 2018  State Representative 2     JAMES RJ STRICKLER 5437. REP   Total  
##  6 2018  State Representative 2     JAMES RJ STRICKLER  318. REP   Absent~
##  7 2018  State Representative 2     JAMES RJ STRICKLER 2833. REP   Early  
##  8 2018  State Representative 2     JAMES RJ STRICKLER 2286. REP   Electi~
##  9 2018  State Representative 3     MARY P SCHILDMEYER 1817. DEM   Total  
## 10 2018  State Representative 3     MARY P SCHILDMEYER  116. DEM   Absent~
## # ... with 1,466 more rows

Shapefiles

For convenience, a collection of shapefiles have additionally been included in the package. Files load as sf geometries, and include the following:

Name Geometry
nm_counties New Mexico counties
nm_places Census designated places in New Mexico
nm_senate_districts State Senate districts in New Mexico
nm_house_districts State House districts in New Mexico
nmel_precincts Voting precincts in New Mexico
us_congress_districts Congressional districts in New Mexico

Elections included in package

nmelectiondatr::nmel_results_summary %>%
  select(Year, Type) %>%
  unique() %>%
  arrange(Type) %>%
  mutate(yes = 'x') %>%
  spread(Year, yes) %>%
  replace(., is.na(.),'') %>%
  knitr::kable()
Type 2014 2016 2018
Attorney General x x
Commissioner of Public Lands x x
Governor and Lieutenant Governor x x
Judge of the Court of Appeals x x
Judge of the Court of Appeals Position 1 x
Judge of the Court of Appeals Position 2 x
Judge of the Court of Appeals Position 3 x
Judge of the Court of Appeals Position 4 x
Judge of the Court of Appeals Position 5 x
Justice of the Supreme Court x x
President and Vice President of the United States x
Secretary of State x x x
State Auditor x x
State Representative x x x
State Senator x
State Treasurer x x
United States Representative x x x
United States Senator x x
You can’t perform that action at this time.