Add scratch.R file.

This commit is contained in:
Nick Hepler 2024-09-26 16:29:13 -04:00
parent 256c7ab040
commit 55be0f38a4

45
scratch.R Normal file
View File

@ -0,0 +1,45 @@
library(readr)
raw <- read_csv("data/alt_fuel_stations (Sep 25 2024)_joined.csv")
library(tidyverse)
dataset <- raw %>%
select(
`Station Name`,
`City`,
`EV Level2 EVSE Num`,
`EV DC Fast Count`,
`Latitude`,
`Longitude`,
`EV Connector Types`,
`EV Workplace Charging`,
`UR20`
)
has_null_ur20 <- dataset %>%
summarise(any_null = any(is.na(UR20)))
dataset <- dataset %>%
filter(!is.na(UR20)) %>%
mutate(UR20 = recode(UR20, "R" = "Rural", "U" = "Urban"))
library(ggplot2)
library(scales)
ggplot(dataset, aes(y = factor(UR20))) +
geom_bar(aes(x = after_stat(count))) +
geom_text(stat = 'count', aes(label = comma(after_stat(count))), # Use comma for thousands separators
position = position_stack(vjust = 0.5),
color = "white") + # Set label color to white
labs(title = "Urban-Rural Station Histogram",
x = "Classification",
y = "Count") +
theme_minimal()
ggplot(dataset, aes(y = factor(UR20))) +
geom_bar(aes(x = after_stat(count))) +
geom_text(stat = 'count', aes(label = comma(after_stat(count))), # Use comma for thousands separators
position = position_stack(vjust = 0.5),
color = "white") + # Set label color to white
labs(title = "Urban-Rural Charger Histogram",
x = "Classification",
y = "Count") +
theme_minimal()