BLS_CleanRawTextFile: Cleans a Raw Bureau of Labor Statistics (BLS) Employment...

Description Usage Arguments Details Value Examples

Description

The BLS Multi-screen data tool http://www.bls.gov/data/#employment can return a tab-seperated file to the web page which you then cut and paste as a .tsv using some text editor. The file needs some cleaning up. While this is pretty simple in the text editor, this function does all that is needed and writes out a new .tsv which imports nicely with read_tsv().

Usage

1
BLS_CleanRawTextFile(fin, fout = NA, append = "_Clean")

Arguments

fin

The path/name if not in home directory

fout

If present, a file path/name for cleaned file. If omitted, fin is used with append appended to file name.

append

A String to append to the string fin. Ignored when fout is not null string.

Details

These cleanups are done: 1) If first line is "Original Data Value", it is removed; 2) First line should now be field names starting with "Series ID". Error is thrown if it isn't; 3) Spaces in field names are replaced with underscores; 4) Numeric values may have "(C)" or "(P)" suffix to flag value as corrected or preliminary respectively; 5) When either "(C)" or "(P)" are present, a legend is appended to the data file. These lines are removed. 6) Any empty lines at end of file are removed.

The cleaned .tsv file is written with append appended to file name.

Value

The path/name of the cleaned file if succussful else an empty string.

Examples

1
2
3
4
## Not run: 
BLS_CleanRawTextFile("data/BLS_NonFarmEmploymentInAreasAL_2015.tsv")

## End(Not run)

ds4ci/dplyrExamples documentation built on May 15, 2019, 2:56 p.m.