Skip to contents

This function checks that the number of variables match between the data set and the data dictionary.

Usage

dimension_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 variables in the data set and data dictionary.

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 (number of variables in the data and dictionary and names of mismatched variables if applicable).

Examples

# Example 1: Fail check
data(ExampleG)
dimension_check(DD.dict.G, DS.data.G)
#> $Status
#> [1] "Failed"
#> 
#> $var.dim
#> Variables in dictionary       Variables in data 
#>                      31                      30 
#> 
#> $mismatches
#>   col_no          Data      Dictionary
#> 1     20    SMOKING_HX SMOKING_HISTORY
#> 2     27 HX_DEPRESSION   DEPRESSION_HX
#> 3     31          <NA>    GENETIC_DATA
#> 
#> $NamesMissingFromDictionary
#> [1] "SMOKING_HX"    "HX_DEPRESSION"
#> 
#> $NamesMissingFromData
#> [1] "SMOKING_HISTORY" "DEPRESSION_HX"   "GENETIC_DATA"   
#> 
print(dimension_check(DD.dict=DD.dict.G, DS.data=DS.data.G,verbose=FALSE))
#> # A tibble: 1 × 5
#>   Time                Function        Status Message                Information 
#>   <dttm>              <chr>           <chr>  <chr>                  <named list>
#> 1 2023-09-27 11:01:15 dimension_check Failed ERROR: the variable c… <named list>

# Example 2: Pass check
data(ExampleA)
dimension_check(DD.dict.A, DS.data.A)
#> $Message
#> [1] "Passed: the variable count matches between the data dictionary and the data."
#> 
#> $Information
#> Variables in dictionary       Variables in data 
#>                      30                      30 
#> 
print(dimension_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:15 dimension_check Passed Passed: the variable c… <int [2]>