knitr::opts_chunk$set(echo = FALSE)

Introduction

This code is part of an assignment from "Buiding R Packages" at Coursera. http://www.coursera.org.

Its main functions are fars_summarise_year and fars_map_state which allo users to produce descriptibe statistics of U.S. traffic accidents by year and month for the former, and to visualise traffic accidents in a given state and year on a simple contour map for the latter.

Data from 2013 to 2015 is available.

Summary statistics

This is an example for 2013 to 2015: fars_summarize_years(c(2013:2015))

suppressMessages(library(fars))
suppressMessages(library(dplyr))
source(file="R/fars_functions.R")
fars_summarize_years(c(2013:2015))

Mapping traffic accidents

This is an example for Florida in 2013: fars_map_state("12","2013")

library(maps)
fars_map_state("12","2013")

Testing the package ouptuts

The function testing() call a pre-defined series of tests.

test_output=fars_summarize_years(c(2013:2015))
testing()


barnabe/building_an_r_package documentation built on May 11, 2019, 6:23 p.m.