diff --git a/README.Rmd b/README.Rmd index 04373ce..a1c1160 100644 --- a/README.Rmd +++ b/README.Rmd @@ -28,6 +28,10 @@ library("openNHTSA") ## Examples +The wrapper currently supports two facilities: [`complaints`](http://www.nhtsa.gov/webapi/Default.aspx?Complaints/Metadata/81) and [`recalls`](http://www.nhtsa.gov/webapi/Default.aspx?Recalls/Metadata/83). Here's an html document showing [how results of the examples should look](https://github.com/statwonk/openNHTSA/blob/master/README.Rmd). + +Complaints are reports filed by vehicle owners with the NHTSA. + ```{r} complaints <- facility("complaints") %>% nhtsa_fetch() diff --git a/README.html b/README.html new file mode 100644 index 0000000..725f38d --- /dev/null +++ b/README.html @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+

openNHTSA

+
+

Convenient access to the NHTSA WebAPIs

+

This package provides some simple helpers for accessing the U.S. Department of Transportation’s National Highway Traffic Safety Administration API from R. It uses the jsonlite and magrittr packages to provide a simple way to convert from National Highway Traffic Safety Administration queries to R dataframes suitable for quick analysis and plotting.

+
+
+

Installation

+

This library has not yet been added to CRAN, so you’ll need the devtools package to install it:

+
install.packages("devtools")
+

Once devtools is installed, you can grab this package:

+
library("devtools")
+devtools::install_github("statwonk/openNHTSA")
+

Load it in like any other package:

+
library("openNHTSA")
+
+
+

Examples

+

The wrapper currently supports two facilities: complaints and recalls. Here’s an html document showing how results of the examples should look.

+

Complaints are reports filed by vehicle owners with the NHTSA.

+
complaints <- facility("complaints") %>%
+  nhtsa_fetch()
+
+head(complaints, 5)
+
##   ModelYear
+## 1      9999
+## 2      2016
+## 3      2015
+## 4      2014
+## 5      2013
+
complaints_2010 <- facility("complaints") %>%
+  model_year("2010") %>%
+  nhtsa_fetch()
+
+head(complaints_2010, 5)
+
##   ModelYear      Make
+## 1      2010    5STARR
+## 2      2010     ACURA
+## 3      2010  AERO CUB
+## 4      2010  AEROLITE
+## 5      2010 AIRSTREAM
+
ford_2010_complaints <- facility("complaints") %>%
+    model_year("2010") %>%
+    vehicle_make("ford") %>%
+    nhtsa_fetch()
+
+head(ford_2010_complaints, 5)
+
##   ModelYear Make          Model
+## 1      2010 FORD CROWN VICTORIA
+## 2      2010 FORD          E-150
+## 3      2010 FORD          E-250
+## 4      2010 FORD          E-350
+## 5      2010 FORD          E-450
+
ford_fusion_2010_complaints <- facility("complaints") %>%
+    model_year("2010") %>%
+    vehicle_make("ford") %>%
+    vehicle_model("fusion") %>%
+    nhtsa_fetch()
+
+str(ford_fusion_2010_complaints)
+
## 'data.frame':    2321 obs. of  15 variables:
+##  $ ODINumber         : int  10270140 10273260 10267371 10281453 10284037 10285614 10287396 10294648 10296446 10299496 ...
+##  $ Manufacturer      : chr  "Ford Motor Company" "Ford Motor Company" "Ford Motor Company" "Ford Motor Company" ...
+##  $ Crash             : chr  "No" "No" "No" "No" ...
+##  $ Fire              : chr  "No" "No" "No" "No" ...
+##  $ NumberOfInjured   : int  0 0 0 0 0 0 0 0 0 0 ...
+##  $ NumberOfDeaths    : int  0 0 0 0 0 0 0 0 0 0 ...
+##  $ DateofIncident    : chr  "/Date(1239336000000-0400)/" "/Date(1243396800000-0400)/" "/Date(1240804800000-0400)/" "/Date(1244692800000-0400)/" ...
+##  $ DateComplaintFiled: chr  "/Date(1243396800000-0400)/" "/Date(1244520000000-0400)/" "/Date(1241064000000-0400)/" "/Date(1251000000000-0400)/" ...
+##  $ Component         : chr  "VISIBILITY" "SERVICE BRAKES, ELECTRIC" "VISIBILITY:WINDSHIELD" "LATCHES/LOCKS/LINKAGES" ...
+##  $ Summary           : chr  "CAR WAS PURCHASED NEW CAR IS 2010 FUSION HYBRID. NOTICED CRACK IN WINDSHIELD STARTING UNDER REARVIEW MIRROR DO WEST FOR APPROX "| __truncated__ "I BOUGHT A 2010 FORD FUSION HYBRID ON MAY 23, 2009 FROM CROWN FORD OF FAYETTEVILLE, NC.   ON MAY 27, WHILE DRIVING DOWN THE ROA"| __truncated__ "TL*THE CONTACT OWNS A 2010 FORD FUSION SPORT. THE CONTACT STATED THAT THE WINDSHIELD CONTAINED A STRESS CRACK DUE TO THE HEAT. "| __truncated__ "THE HOOD ON MY 2010 FORD FUSION HYBRID UNLATCHES ITSELF AT INTERSTATE HIGHWAY SPEED. THE SAFETY CATCH HAS SUCCESSFULLY RESTRAIN"| __truncated__ ...
+##  $ ProductType       : chr  "VEHICLE" "VEHICLE" "VEHICLE" "VEHICLE" ...
+##  $ ModelYear         : chr  "2010" "2010" "2010" "2010" ...
+##  $ Make              : chr  "FORD" "FORD" "FORD" "FORD" ...
+##  $ Model             : chr  "FUSION" "FUSION" "FUSION" "FUSION" ...
+##  $ VIN               : chr  NA "3FADP0L35AR" "3FAHP0KC2AR" "3FADP0L33AR" ...
+
+
+

Acknowledgment

+

I highly admire the functional programming technique used by the authors of the openfda API wrapper (@rjpower and @leeper). Much of the code and documentation in this package is directly copied from that wrapper. That package is licenced under GPLv2, and so this package is also licened under the same licence. If either @rjpower or @leeper read this and would like to be made an author, I’ll happily add them. :)

+
+
+ + +
+ + + + + + + + diff --git a/README.md b/README.md index 04373ce..8b97080 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,10 @@ library("openNHTSA") ## Examples +The wrapper currently supports two facilities: [`complaints`](http://www.nhtsa.gov/webapi/Default.aspx?Complaints/Metadata/81) and [`recalls`](http://www.nhtsa.gov/webapi/Default.aspx?Recalls/Metadata/83). Here's an rmarkdown document showing [how results of the examples should look](https://github.com/statwonk/openNHTSA/blob/master/README.Rmd). + +Complaints are reports filed by vehicle owners with the NHTSA. + ```{r} complaints <- facility("complaints") %>% nhtsa_fetch()