This function flags variables that have values exceeding the MIN
or MAX
listed in the data dictionary.
Arguments
- DD.dict
Data dictionary.
- DS.data
Data set.
- verbose
When TRUE, the function prints the Message out, as well as a list of variables that violate the listed
MIN
orMAX
.- non.NA.missing.codes
A user-defined vector of numerical missing value codes (e.g., -9999).
Value
Tibble, returned invisibly, containing: (1) Time (Time stamp); (2) Name (Name of the function); (3) Status (Passed/Failed); (4) Message (A copy of the message the function printed out); (5) Information (A list of variables that exceed the listed MIN
or MAX
values).
Examples
# Example 1
# Fail check (incorrectly flagging NA value codes -9999
# and -4444 as outside of the min max range)
data(ExampleA)
minmax_check(DD.dict.A, DS.data.A)
#> $Message
#> [1] "ERROR: some variables have values outside of the MIN to MAX range."
#>
#> $Information
#> # A tibble: 1 × 5
#> Trait Check ListedMin ListedMax OutOfRangeValues
#> <chr> <lgl> <dbl> <dbl> <list>
#> 1 PREGNANT FALSE 0 1 <int [2]>
#>
# View out of range values:
details <- minmax_check(DD.dict.A, DS.data.A)$Information
#> $Message
#> [1] "ERROR: some variables have values outside of the MIN to MAX range."
#>
#> $Information
#> # A tibble: 1 × 5
#> Trait Check ListedMin ListedMax OutOfRangeValues
#> <chr> <lgl> <dbl> <dbl> <list>
#> 1 PREGNANT FALSE 0 1 <int [2]>
#>
details[[1]]$OutOfRangeValues
#> [[1]]
#> [1] -4444 -9999
#>
# Attempt 2, specifying -9999 and -4444 as missing value
# codes so check works correctly
minmax_check(DD.dict.A, DS.data.A, non.NA.missing.codes=c(-9999, -4444))
#> $Message
#> [1] "Passed: when provided, all variables are within the MIN to MAX range."
#>
# Example 2
data(ExampleI)
minmax_check(DD.dict.I, DS.data.I, non.NA.missing.codes=c(-9999, -4444))
#> $Message
#> [1] "ERROR: some variables have values outside of the MIN to MAX range."
#>
#> $Information
#> # A tibble: 1 × 5
#> Trait Check ListedMin ListedMax OutOfRangeValues
#> <chr> <lgl> <dbl> <dbl> <list>
#> 1 PERCEIVED_CONFLICT FALSE 1 15 <tibble [11 × 1]>
#>
# View out of range values:
details <- minmax_check(DD.dict.I, DS.data.I, non.NA.missing.codes=c(-9999, -4444))$Information
#> $Message
#> [1] "ERROR: some variables have values outside of the MIN to MAX range."
#>
#> $Information
#> # A tibble: 1 × 5
#> Trait Check ListedMin ListedMax OutOfRangeValues
#> <chr> <lgl> <dbl> <dbl> <list>
#> 1 PERCEIVED_CONFLICT FALSE 1 15 <tibble [11 × 1]>
#>
details[[1]]$OutOfRangeValues
#> [[1]]
#> # A tibble: 11 × 1
#> PERCEIVED_CONFLICT
#> <int>
#> 1 25
#> 2 24
#> 3 16
#> 4 28
#> 5 17
#> 6 21
#> 7 30
#> 8 19
#> 9 26
#> 10 20
#> 11 29
#>