From 55be0f38a49da2e7d7eeea6e62e5a2003139dfc5 Mon Sep 17 00:00:00 2001 From: Nick Hepler Date: Thu, 26 Sep 2024 16:29:13 -0400 Subject: [PATCH] Add scratch.R file. --- scratch.R | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 scratch.R diff --git a/scratch.R b/scratch.R new file mode 100644 index 0000000..a8ed377 --- /dev/null +++ b/scratch.R @@ -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() \ No newline at end of file