knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
LPfars is a package that was built for the purposes of the Coursera course Building R Packages
The goal of LPfars is to read and summarise the monthly injuries, and plot the density of fatal injuries on a map
You can install the released version of LPfars from Github with:
devtools::install_github("lefkiospaikousis/LPfars")
The fars_summarize_years
returns a summary table with the number of monthly accident cases (row) and the defined year(s) (column). Here the input parameter canbe a numeric vector or a list of the year values.
library(LPfars) # Set the working directory to the location of the files # This is for demontrating purposes. Once you have your datasets in your current working directory, you will not have to do this files_location = system.file("extdata", package = "LPfars") setwd(files_location) fars_summarize_years(2013:2015)
The package re-exports the %>%
operator from the package magritrr
so you can perfom exploratory analysis the tidyverse
way!
The Fatality Analysis Reporting System (FARS) contains data derived from a US nationwide census regarding fatal injuries suffered in motor vehicle traffic crashes
See here on how to create datasets and use the package
You can find the location of the example csv files on your disk by typing
system.file("extdata", package = "LPfars")
Also, you can get the file name of the an example data by typing
system.file("extdata", "accident_2013.csv.bz2", package = "LPfars")
The LPfars package has five functions:
The fars_read
function for reading the data in R as a csv file
The fars_read_years
function that reads multiple csv files from disk
The fars_summarize_years
function for comparing monthly summaries
The The fars_map_state
function to create a map plot where the accidents occurred
The make_filename
function that concatenates string values and creates a filename in a standard format of accident_YEAR.csv.bz2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.