knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The farsdata
package contains data from the Fatality Analysis Reporting System (FARS) for fatal automobile crashes in the United States.
There are two ways to install it.
You can install the beta version of farsdata from GitHub with:
devtools::install_github("kjhealy/farsdata")
drat
While using install_github()
works just fine, it would be nicer to be able to just type install.packages("farsdata")
or update.packages("farsdata")
in the ordinary way. We can do this using Dirk Eddelbuettel's drat package. Drat provides a convenient way to make R aware of package repositories other than CRAN.
First, install drat
:
if (!require("drat")) { install.packages("drat") library("drat") }
Then use drat
to tell R about the repository where farsdata
is hosted:
drat::addRepo("kjhealy")
You can now install farsdata
:
install.packages("farsdata")
To ensure that the farsdata
repository is always available, you can add the following line to your .Rprofile
or .Rprofile.site
file:
drat::addRepo("kjhealy")
With that in place you'll be able to do install.packages("farsdata")
or update.packages("farsdata")
and have everything work as you'd expect.
Note that the drat repository only contains data packages that are not on CRAN, so you will never be in danger of grabbing the wrong version of any other package.
The package works best with the tidyverse libraries and the simple features package for mapping.
library(tidyverse)
Load the data:
library(farsdata)
Look at it:
vehicles
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.