Skip to contents

Checks for NA values in the data set; if NA values are present, also performs check for NA value=meaning.

Usage

NA_check(DD.dict, DS.data, verbose = TRUE)

Arguments

DD.dict

Data dictionary.

DS.data

Data set.

verbose

When TRUE, the function prints the Message out, as well as the number of NA values observed in the data set.

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 (the number of NA values in the data set and information on if NA is a properly encoded value).

Examples

# Example 1: Fail check
data(ExampleK)
NA_check(DD.dict.K, DS.data.K)
#> $Message
#> [1] "Error: your data set contains NA values with no encoded NA value=meaning found. If you choose to retain NA values, NA must be specified as a missing value code in VALUES fields as a dbGaP requirement."
#> 
#> $Information
#> [1] "There are 112 NA values in your data set."
#> 
print(NA_check(DD.dict.K, DS.data.K, verbose=FALSE))
#> # A tibble: 1 × 5
#>   Time                Function Status Message                        Information
#>   <dttm>              <chr>    <chr>  <chr>                          <named lis>
#> 1 2023-09-27 11:01:07 NA_check Failed Error: your data set contains… <chr [1]>  

# Example 2: Pass check
data(ExampleA)
NA_check(DD.dict.A, DS.data.A)
#> $Message
#> [1] "Passed: no NA values detected in data set."
#> 
print(NA_check(DD.dict.A, DS.data.A, verbose=FALSE))
#> # A tibble: 1 × 5
#>   Time                Function Status Message                        Information
#>   <dttm>              <chr>    <chr>  <chr>                          <named lis>
#> 1 2023-09-27 11:01:08 NA_check Passed Passed: no NA values detected… <chr [1]>  

# Example 3: Pass check (though missing_value_check detects a more specific error)
data(ExampleS)
NA_check(DD.dict.S, DS.data.S)
#> $Message
#> [1] "Passed: your data set contains NA values that appear to be correctly specified as a missing value code in the VALUES fields."
#> 
#> $Information
#> [1] "There are 50 NA values in your data set."
#>