knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) library(caRecall) library(dplyr) library(ggplot2) library(RColorBrewer)
The caRecall
package is an API wrapper for the Government of Canada Vehicle Recalls Database (VRD) used by the Defect Investigations and Recalls Division for vehicles, tires, and child car seats. The API wrapper provides access to recall summary information searched using make, model, and year range, as well as detailed recall information searched using recall number.
The package focuses on querying data from the VRD API to return the following:
You can install the released version 0.1.0 of caRecall from CRAN with:
install.packages("caRecall")
The development version of the caRecall
package can be installed from GitHub with:
# install.packages("devtools") devtools::install_github("WraySmith/caRecall")
More documentation on caRecall
can found at: https://wraysmith.github.io/caRecall/
Note that an API key is required to run the functions in caRecall
and query the Vehicle Recalls Database. The key can be acquired at https://tc.api.canada.ca/en/detail?api=VRDB.
A simple example of using the recall_by_years()
function in the package to return all recalls manufactured in 2000 could be done as follows:
recall_summary_2000 <- recall_by_years(start_year = 2000, end_year = 2000, limit = 3000) recall_summary_2000
The data could then be used to summarize manufacturers with the highest recall counts in the year:
counts_manu_2000 <- recall_summary_2000 %>% group_by(`Manufacturer Name`) %>% tally() %>% filter(n >= 50) nb.cols <- 11 mycolors <- colorRampPalette(brewer.pal(8, "Set2"))(nb.cols) fig <- counts_manu_2000 %>% ggplot() + aes(x=`Manufacturer Name`, y=n, fill=`Manufacturer Name`) + scale_fill_manual(values = mycolors) + geom_col() + geom_text(aes(label=n), vjust=-.5, size=3) + labs(y="Recall Count") + theme(axis.text.x = element_blank(), axis.title.x = element_blank(), axis.ticks.x = element_blank(), axis.title.y = element_text(size = 10), axis.line = element_line(color = "black"), legend.title = element_text(size = 10), legend.text = element_text(size = 7), plot.title = element_text(size = 12)) + scale_y_continuous(expand = c(0,0), limits = c(0,250)) + ggtitle("Manufacturers with Most Recalls in 2000")
fig
Additionally, detailed recall information can be queried from the API using the recall_details()
function:
recall_windstar <- recall_details(1997118) tibble(t(recall_windstar)) #transpose for readability here
To report bugs/issues/feature requests, please file an issue.
These are very welcome!
If you would like to contribute to the package, please see our CONTRIBUTING guidelines.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.