What it covers
The Indiana scraper returns General Election results from the Indiana
Election Division at enr.indianavoters.in.gov. It covers
General Elections only (not primaries or special elections) from 2019 to
the present.
Results are fetched from the FirstTuesday archive JSON API and include statewide candidate totals and county-level breakdowns for all Federal, State, and Local office categories.
Note: The Indiana site is a JSON API (no browser required). Scraping is fast relative to Playwright-based states. County-level data covers all 92 Indiana counties.
Indiana is the running example in the Example analyses vignette, which demonstrates filtering by office, counting party wins, margin calculations, and county-level swing analysis.
Arguments
| Argument | Default | Description |
|---|---|---|
state |
— |
"IN", "indiana", or
"Indiana"
|
year_from |
NULL |
Start year, inclusive; NULL = no lower bound (clamped
to 2019) |
year_to |
NULL |
End year, inclusive; NULL = current calendar year |
level |
"all" |
"all" — statewide + county; "state" —
statewide only; "county" — county-level only |
Examples
Statewide + county results for a single year
res <- scrape_elections(state = "IN", year_from = 2024, year_to = 2024)
# Statewide candidate totals
res$state %>%
filter(office_level == "Federal") %>%
select(election_year, office, candidate, party, votes, vote_pct, winner)
# County-level breakdown
res$county %>%
filter(office == "President of the United States") %>%
select(county_name, candidate, party, votes, vote_pct) %>%
arrange(county_name, desc(votes))Statewide totals only (faster — skips county scraping)
state_df <- scrape_elections(
state = "IN",
year_from = 2024,
year_to = 2024,
level = "state"
)
state_df %>%
select(election_year, office_level, office, candidate, party, votes, vote_pct, winner)Multi-year scrape
res <- scrape_elections(
state = "IN",
year_from = 2020,
year_to = 2024,
level = "state"
)
res %>%
filter(office == "President of the United States") %>%
select(election_year, candidate, party, votes, vote_pct, winner)Filter by office level
res <- scrape_elections(state = "IN", year_from = 2024, year_to = 2024)
# Federal races only
res$state %>%
filter(office_level == "Federal") %>%
select(office, candidate, party, votes, vote_pct, winner)
# State races only
res$state %>%
filter(office_level == "State") %>%
select(office, candidate, party, votes, vote_pct, winner)Output columns
$state (when level = "all" or
"state")
| Column | Description |
|---|---|
state |
State abbreviation ("IN") |
election_year |
Calendar year of the election |
election_date |
Date of the election |
election_type |
Always "General"
|
office_level |
"Federal", "State", or
"Local"
|
office |
Office name
(e.g. "President of the United States") |
district |
District identifier; NA when not applicable |
candidate |
Candidate name as printed on the ballot |
party |
Full party name (e.g. "Republican",
"Democrat") |
votes |
Statewide vote total |
vote_pct |
Percentage of votes within the contest |
winner |
TRUE if the candidate won |
num_seats |
Number of seats available in the contest |
$county (when level = "all" or
"county")
| Column | Description |
|---|---|
state |
State abbreviation ("IN") |
election_year |
Calendar year of the election |
election_date |
Date of the election |
election_type |
Always "General"
|
office_level |
"Federal", "State", or
"Local"
|
office |
Office name |
district |
District identifier; NA when not applicable |
county_name |
County name |
candidate |
Candidate name as printed on the ballot |
party |
Full party name |
votes |
County-level vote total |
vote_pct |
Percentage of votes within the contest for this county |
county_winner |
TRUE if the candidate won within this county |
num_seats |
Number of seats available in the contest |
Performance notes
- Fast scraper. Indiana uses a JSON API — no headless browser is required. A full statewide + county scrape for one year typically completes in under a minute.
- General Elections only. The scraper covers General Elections only. Primary and special election results are not available through this source.
- Local races. County-level data includes Local office races (county treasurer, clerk, etc.) in addition to Federal and State races.