Checks if an object is a valid data dictionary and returns it with the appropriate madshapR::class attribute. This function mainly helps validate inputs within other functions of the package but could be used to check if an object is valid for use in a function.

as_data_dict(object)

Arguments

object

A potential data dictionary object to be coerced.

Value

A list of data frame(s) with madshapR::class 'data_dict'.

Details

A data dictionary contains the list of variables in a dataset and metadata about the variables and can be associated with a dataset. A data dictionary object is a list of data frame(s) named 'Variables' (required) and 'Categories' (if any). To be usable in any function, the data frame 'Variables' must contain at least the name column, with all unique and non-missing entries, and the data frame 'Categories' must contain at least the variable and name columns, with unique combination of variable and name.

See also

For a better assessment, please use data_dict_evaluate().

Examples

{

# use madshapR_DEMO provided by the package

data_dict <- madshapR_DEMO$data_dict_PARIS
as_data_dict(data_dict)

}
#> $Variables
#> # A tibble: 7 × 7
#>   name     typeof    index `label:fr`      `description:fr`      valueType unit 
#>   <chr>    <chr>     <chr> <chr>           <chr>                 <chr>     <chr>
#> 1 ID       character 1     id              id du participant     text      NA   
#> 2 SEX      integer   2     Sexe            Sexe du participant … integer   NA   
#> 3 BMI      double    3     IMC             Indice de Masse Corp… decimal   kg/m…
#> 4 AGE      integer   4     Age             Age du Participant    integer   years
#> 5 SMO      integer   5     Fumeur          Fumeur regulier       integer   NA   
#> 6 SMO_QTY  integer   6     fum_qte_semaine nombre de cigarettes… integer   ciga…
#> 7 PRG_EVER integer   7     enceinte_occur  Si la personne a dej… integer   NA   
#> 
#> $Categories
#> # A tibble: 9 × 5
#>   variable name  labels `label:fr`                                     missing
#>   <chr>    <chr> <chr>  <chr>                                          <chr>  
#> 1 SEX      0     0      Homme                                          FALSE  
#> 2 SEX      1     1      Femme                                          FALSE  
#> 3 SMO      0     0      Non-Fumeur                                     FALSE  
#> 4 SMO      1     1      Fumeur (cigarette ; cigare)                    FALSE  
#> 5 SMO_QTY  -8    -8     SKIP PATTERN                                   FALSE  
#> 6 PRG_EVER -8    -8     SKIP PATTERN                                   TRUE   
#> 7 PRG_EVER 0     0      Jamais enceinte (nb grossesse = 0)             FALSE  
#> 8 PRG_EVER 1     1      Enceinte au moins une fois (nb grossesse => 1) FALSE  
#> 9 PRG_EVER 9     9      NSP                                            TRUE   
#> 
#> attr(,"madshapR::class")
#> [1] "data_dict"