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

as_data_dict_shape(object)

Arguments

object

A potential valid data dictionary to be coerced.

Value

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

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_shape(data_dict)

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