To show only the results, large code chunks are hidden, but can be unfolded by clicking the “Code” boxes on the top right of each hidden code chunk.
Data Cleaning
The first step is loading the data, removing unnecessary columns and modifying columns with information from the documentation. I used the very handy clean_names function from the janitor package, which removes the all caps and spaces on the column headers. The case_when function from dplyr is very useful for mutating a new column on a data frame conditionally on another column.
At this stage, we have a nice and large dataset, which can be used for visualisation. The following sections will answer questions I was interested in while looking at the data.
How Are Alternative Fuel Stations Distributed Across The US?
Code
us <-map_data('state')fuel %>%filter(!fuel_type %in%c("Liquified Natural Gas")) %>%ggplot(aes(x = longitude, y = latitude)) +geom_polygon(data = us, aes(x = long, y = lat, group = group),color ='gray', fill ="gray95", alpha =0.3, size =0.25) +geom_point(aes(colour = status_code), alpha =0.25, size =0.5) +facet_wrap(~ fuel_type) +scale_size_continuous(range =c(0.5, 4), labels = scales::comma_format(suffix =" MW")) +xlim(-125, -65) +ylim(20, 50) +labs(title ="Alternative Fuel Stations in the USA",subtitle ="The Alternative Fueling Stations dataset is recent as of July 06, 2022.\nSource: U.S. Department of Transportation (USDOT)/Bureau of Transportation Statistics (BTS)",y =NULL,x =NULL,colour ="Status") +coord_map() +scale_colour_manual(values =c("#1E88E5", "#FBC02D", "#C62828")) +guides(colour =guide_legend(override.aes =list(size =3))) +theme_minimal() +theme(plot.background =element_rect(colour ="white"),panel.grid =element_blank(),axis.ticks =element_blank(),axis.line =element_blank(),axis.text =element_blank(),plot.title =element_text(size =14, face ="bold", colour ="black"),plot.subtitle =element_text(face ="italic", colour ="gray50",size =10),strip.text =element_text(face ="bold"),legend.position ="bottom")
Generally, it becomes clear that electricity is the most common alternative fuel source in the US. The next categories are ethanol and propane, the first of which is centred around the corn belt states, which have emerged from their former rust belt status. As ethanol is most commonly made from the biomass of corn, the correlation to local production is not surprising. Another thing that catches the eye is the particular distribution of biodiesel in two clusters. Reasons include strong tax incentives for this particular alternative fuel in these states. Lastly, the development of hydrogen is the weakest. There are virtually no fuelling stations for the latter and only some are planned in California and Connecticut.
How Many Fuel Stations Are There For Each Category?
Code
fuel %>%count(fuel_type) %>%ggplot(aes(x = n,y = fuel_type %>%fct_reorder(n))) +geom_col(fill ="midnightblue") +labs(title ="Frequency Of Alternative Fuel Stations In The US",subtitle ="The Alternative Fueling Stations dataset is recent as of July 06, 2022.\nSource: U.S. Department of Transportation (USDOT)/Bureau of Transportation Statistics (BTS)",y =NULL,x ="Frequency") +scale_x_continuous(labels = scales::comma_format()) +theme_minimal() +theme(plot.title =element_text(size =14, face ="bold", colour ="black"),plot.subtitle =element_text(face ="italic", colour ="gray50",size =10),panel.grid.major.y =element_blank())
What About Fast Charging Stations For Electric Vehicles?
Code
fuel %>%summarise("Level 2 Charging Available"=mean(!is.na(ev_level2_evse_num)),"DC Fast Charging Available"=mean(!is.na(ev_dc_fast_count)))
# A tibble: 1 × 2
`Level 2 Charging Available` `DC Fast Charging Available`
<dbl> <dbl>
1 0.745 0.103
3 out of 4 electric charging stations have fast chargers (Level 2 - up to 8x faster than regular home charger) available. Only 1 out of 10 stations has DC fast charging, which is capable of charging your electric vehicle almost fully in less than an hour. For the stations with DC fast charging, how many places are available?
Code
fuel %>%filter(!is.na(ev_dc_fast_count)) %>%ggplot(aes(ev_dc_fast_count)) +geom_histogram(binwidth =2, fill ="midnightblue") +labs(title ="Number Of Fast Chargers At Electric Charging Stations",subtitle ="The Alternative Fueling Stations dataset is recent as of July 06, 2022.\nSource: U.S. Department of Transportation (USDOT)/Bureau of Transportation Statistics (BTS)",y =NULL,x ="Frequency") +scale_x_continuous(labels = scales::comma_format()) +scale_y_continuous(labels = scales::comma_format()) +theme_minimal() +theme(plot.title =element_text(size =14, face ="bold", colour ="black"),plot.subtitle =element_text(face ="italic", colour ="gray50",size =10),panel.grid.major.y =element_blank())
The exceeding majority of stations have less than 10 DC charging spaces available.
How Are DC Fast Charging Stations Distributed Across The US?
Code
fuel %>%filter(fuel_type_code =="ELEC",!is.na(open_date)) %>%mutate(open_date =ymd_hms(open_date),open_year =year(open_date)) %>%filter(open_year >2010) %>%mutate(time_period =cut(open_year, seq(2000, 2022, 2), dig.lab =5)) %>%filter(!is.na(ev_dc_fast_count)) %>%ggplot(aes(x = longitude, y = latitude)) +geom_polygon(data = us, aes(x = long, y = lat, group = group),color ='gray', fill ="gray95", alpha =0.3, size =0.25) +geom_point(aes(colour = time_period), alpha =0.4, size =0.5) +xlim(-125, -65) +ylim(20, 50) +labs(title ="Electric Car Fast Charging Stations in the USA",subtitle ="DC fast charging charge some EVs to 80 percent in 20-30 minutes. \nThe Alternative Fueling Stations dataset is recent as of July 06, 2022.\nSource: U.S. Department of Transportation (USDOT)/Bureau of Transportation Statistics (BTS)",y =NULL,x =NULL,colour ="Built in") +coord_map() +scale_color_brewer(palette ="RdYlBu") +guides(colour =guide_legend(override.aes =list(size =3))) +theme_minimal() +theme(plot.background =element_rect(colour ="white"),panel.grid =element_blank(),axis.ticks =element_blank(),axis.line =element_blank(),axis.text =element_blank(),plot.title =element_text(size =14, face ="bold", colour ="black"),plot.subtitle =element_text(face ="italic", colour ="gray50",size =10),strip.text =element_text(face ="bold"),legend.position ="right")
From the map, the highway systems in the US become visible. Fast charging stations cluster around large cities and next to the large highways. Strikingly, the vast majority of fast charging stations have been built over the past two years.