Data from SLMPD are released with a number of problems that cs_validate is designed to identify.

cs_validate(.data, year, verbose = FALSE)

Arguments

.data

A tbl

year

A string representing the year being checked, e.g. "2008"

verbose

A logical scalar. If TRUE, a full validation report summarizing results will be returned. If FALSE, a single value will be returned.

Value

A tibble with validation results.

Details

cs_validate performs a total of five checks on the given year-list object. Each test is summarized in the verbose = TRUE output:

valMonth

Each tibble within a year-list is named for the month it represents. Does the named month match the month that the data represent?

valYear

Does the year provided for the year argument match the year that the data represent?

oneMonth

Does each tibble represent only one month of data?

varCount

Does each tibble have the correct number of variables (20)?

valVars

Does each tibble have the correct variable names?

For all months prior to 2013 and approximately half of the months during 2013, SLMPD data are released with 18 variables. For one month, May 2017, the data are released with 26 variables. These problems are identified most easily by using cs_validate.

Examples

# load example year-list object load(system.file("testdata", "yearList17.rda", package = "compstatr", mustWork = TRUE)) # simple validation cs_validate(yearList17, year = 2017)
#> [1] FALSE
# verbose validation cs_validate(yearList17, year = 2017, verbose = TRUE)
#> # A tibble: 12 x 8 #> namedMonth codedMonth valMonth codedYear valYear oneMonth varCount valVars #> <chr> <chr> <lgl> <int> <lgl> <lgl> <lgl> <lgl> #> 1 January January TRUE 2017 TRUE TRUE TRUE TRUE #> 2 February February TRUE 2017 TRUE TRUE TRUE TRUE #> 3 March March TRUE 2017 TRUE TRUE TRUE TRUE #> 4 April April TRUE 2017 TRUE TRUE TRUE TRUE #> 5 May May TRUE 2017 TRUE TRUE FALSE NA #> 6 June June TRUE 2017 TRUE TRUE TRUE TRUE #> 7 July July TRUE 2017 TRUE TRUE TRUE TRUE #> 8 August August TRUE 2017 TRUE TRUE TRUE TRUE #> 9 September September TRUE 2017 TRUE TRUE TRUE TRUE #> 10 October October TRUE 2017 TRUE TRUE TRUE TRUE #> 11 November November TRUE 2017 TRUE TRUE TRUE TRUE #> 12 December December TRUE 2017 TRUE TRUE TRUE TRUE