iowa | R Documentation |
A data frame containing information about the 2016 US Presidential Election for the state of Iowa.
iowa
A data frame with 1386 observations on the following 5 variables.
The office that the candidates were running for.
President/Vice President pairs who were running for office.
Political part of the candidate.
County in Iowa where the votes were cast.
Number of votes received by the candidate.
library(ggplot2)
library(dplyr)
plot_data <- iowa |>
filter(candidate != "Total") |>
group_by(candidate) |>
summarize(total_votes = sum(votes) / 1000)
ggplot(plot_data, aes(total_votes, candidate)) +
geom_col() +
theme_minimal() +
labs(
title = "2016 Presidential Election in Iowa",
subtitle = "Popular vote",
y = "",
x = "Number of Votes (in thousands)
"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.