This dataset shows the Battery Electric Vehicles (BEVs) and Plug-in Hybrid Electric Vehicles (PHEVs) that are currently registered through Washington State Department of Licensing (DOL)
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.3 ✔ readr 2.1.4
✔ forcats 1.0.0 ✔ stringr 1.5.0
✔ ggplot2 3.4.4 ✔ tibble 3.2.1
✔ lubridate 1.9.2 ✔ tidyr 1.3.0
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Rows: 159467 Columns: 17
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (11): VIN (1-10), County, City, State, Make, Model, Electric Vehicle Typ...
dbl (6): Postal Code, Model Year, Electric Range, Base MSRP, Legislative Di...
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
ggplot(recent_evs, aes(x =`Model Year`, y =`Electric Range`, color = Make)) +geom_jitter(alpha =0.5, width =0.2, height =0) +# Using jitter to avoid overplottingfacet_wrap(~Make, scales ="free_y", ncol =4) +# Set number of columns to avoid squeezed facetsscale_color_viridis_d() +labs(title ="Electric Vehicle Range by Make and Model Year",x ="Model Year",y ="Electric Range (miles)",color ="Make") +theme_minimal() +theme(legend.position ="bottom",axis.text.x =element_text(angle =45, hjust =1),plot.title =element_text(size =14, face ="bold"),strip.text.x =element_text(size =10, face ="bold")) +guides(color =guide_legend(override.aes =list(size=4)))
ggsave("EV_Range_Plot.png", width =20, height =15, units ="cm")