Description Usage Arguments Value Note Source Examples
Reading FARS files from working directory with given YEARS argument into tbl_df object of dplyr package. Returns data from which all variables(columns) except YEAR and MONTH are removed. After reading the files dplyr with pipes(magrittr) are used to create new column year, and then remove all columns, except MONTH and YEAR.
1 | fars_read_years(years)
|
years |
A vector of years, provided as a character vector or as an integer vector. Provide the years in 4-digit format to ensure the correct file can be found for that year. If any of the years is absent from the FARS dataset, a NULL value is returned for that year. Files need to be in working directory. |
A list of tibble data-frames containing the FARS dataset for each year in the input set. The entry is NULL for any year that is absent from the FARS dataset.
Function use make_filename(year) and fars_read(year) functions, and readr, dplyr and magrittr packages.
Coursera, Building R Packages
1 2 3 4 5 | setwd(dirname(system.file("extdata","accident_2013.csv.bz2",package = "fars")))
fry<-fars_read_years(c(2013))
str(fry)
summary(fry)
fry[1]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.