Here is the code for the House and Senate trackers:
# Required packages
if (!require("tidyverse"))
install.packages("tidyverse")
if (!require("plotly"))
install.packages("plotly")
if (!require("DataEditR"))
install.packages("DataEditR")
library(tidyverse)
library(plotly)
library(DataEditR)
# Read data
House <- read_csv("House.csv")
House <- data_edit(House)
write_csv(House,"House.csv")
# Totaling members by party
Dem <- sum(House$Dem)
Rep <- sum(House$Rep)
Unallocated <- sum(House$Unallocated)
Party <- c("Dem", "Rep", "Unallocated")
Members <- c(Dem, Rep, Unallocated)
ChartData <- data.frame(Party, Members)
# Making the plot
fig <- plot_ly(
ChartData,
x = ~ Party,
y = ~ Members,
marker = list(color = c("384B70", "B8001F", "gray")),
type = "bar",
text = Members,
textposition = "auto")
fig
# Required packages
if (!require("tidyverse"))
install.packages("tidyverse")
if (!require("plotly"))
install.packages("plotly")
if (!require("DataEditR"))
install.packages("DataEditR")
library(tidyverse)
library(plotly)
library(DataEditR)
# Read data
Senate <- read_csv("Senate.csv")
Senate <- data_edit(Senate)
write_csv(Senate,"Senate.csv")
# Totaling members by party
Dem <- sum(Senate$Dem)
Rep <- sum(Senate$Rep)
Ind <- sum(Senate$Ind)
Unallocated <- sum(Senate$Unallocated)
Party <- c("Dem", "Rep", "Ind", "Unallocated")
Members <- c(Dem, Rep, Ind, Unallocated)
ChartData <- data.frame(Party, Members)
# Making the plot
fig <- plot_ly(
ChartData,
x = ~ Party,
y = ~ Members,
marker = list(color = c("384B70", "B8001F", "507687", "gray")),
type = "bar",
text = Members,
textposition = "auto")
# Showing the plot
fig