When possible data was retrieved using the Open States Data API in R.
Otherwise, data was retrieved from state legislature websites and other publicly available information.
Available data varied by state - some states had the results for every available election, while for others, no data was available for even presidential elections