This project aims to collect data about Framingham, Massachusetts and wrangle it so it is in a form useful for analysis. It focuses largely on election results for now – more specifically local mayoral and City Council races as well as turnout information – but there are other files here such as precinct shapefiles and property records.

See a searchable table of available data files below. If you know regular expressions, those work in the search and filter boxes.

Election data

Election data is in one of two structures – “tidy”, sometimes called “long”, with one observation in each row; or more human-readable format, with multiple data points per row. Tidy election data files are in the data/elections/tidy subdirectory.

If you are doing analysis in R and other platforms (including as a basis for Excel pivot tables), tidy format is more useful. If you want to combine data sets, tidy is definitely more useful since most tidy data sets have the same column names: Candidate, District or Precinct, Votes, Race, Year, Election.

If you are just looking to see results, the non-tidy format will likely be more useful. Those files are in the data/elections directory.

The data generally start in 2017 with Framingham’s transition from town to city form of government, although I have a few raw data files from earlier elections. I do not include preliminary elections unless they are city-wide.

Source: Local election data generally come from PDFs of results provided by the Framingham City Clerk’s office. I then extract data from PDF into Excel files using the CometDocs cloud service or PDF Tables and do a fair amount of data wrangling on those results.

What’s where

Search available files

R users: You can read shapefiles into R with the sf package, such as

Info on reproducibility

These are some of the scripts I used to turn raw data into analysis-friendly data:

R/election_general_2017_framingham.R – R file to convert November 2017 official results spreadsheet to an analysis-friendly format.

R/election_preliminary_2017_framingham.R – R file to convert September 2017 official results spreadsheet to an analysis-friendly format.

R/election_charter_2017.R – R file to convert April 2017 city charter results to analysis-friendly format.

R/election_general_2019.R – R file to convert November 2017 official results data to an analysis-friendly format.

R/election_helpers.R – file with some useful functions for working with Framingham election data.

R/election_preliminary_2021_framingham.R – R file to process September 2021 election data.