fars_read: Read data from a CSV (Comma Separated Value) file

Description Usage Arguments Details Value Note Examples

Description

This functions reads a flat file (text file encoded in ASCII) in the current working directory and returns it as an object of the "tbl_df" class. If the file does not exist in the current directory, this function stops execution with an error message. The progress while the file is being read is not displayed. Similarly, messages are also suppressed. It is an internal (supporting) function used by other functions in this package.

Usage

1
fars_read(filename)

Arguments

filename

A character string containing the name of the csv file to be read, residing in the current working directory. CSV file can also be compressed as allowed by the readr package's read_csv() function.

Details

This function uses the read_csv() function from the readr package, with progress = FALSE parameter. After reading the data from the csv file, the tbl_df() function from the dplyr package is called to convert the data into the tabl_df format before returing it. This function is also exported, so users will have direct access to it when they load the package conataining this function.

Value

This function returns an object of class "tbl_df" (table dataframe) from the dplyr package.

Note

The file passed as a parameter (filename) must exist in the current working directory. Otherwise, this function stops execution with an error message: "file 'filename' does not exist".

Examples

1
2
3
4
5
## Not run: 
fars_read("accident_2014.csv.bz2") # file in current working directory
fars_read("abc123xyz.csv") # Error: File 'abc123xyz.csv' does not exist.

## End(Not run)

masabri01/BuildingRPackagesCoursera documentation built on May 21, 2019, 12:39 p.m.