Using the FARS Data

Let's Load the package into namespace. We'll also need the stats and maps packages:

library(fars)
library(stats)
library(maps)

Now I can read in one of the data files using the fars_read() function from the package:

df_2013 <- fars_read('data/accident_2013.csv.bz2')

This gives 30202 observations of 50 variables. Using a different function from fars, I could have also created the filename automatically:

file_name <- make_filename(2013)
data_path <- file.path('data/accident_2013.csv.bz2')

You can also input multiple years:

multiyear <- fars_read_years(c(2013,2015))

Or summarize multiple years:

fars_summarize_years(c(2013,2014))


12mre1/fars documentation built on Oct. 30, 2019, 4:02 a.m.