Applies category labels declared in a data dictionary to the associated columns (variables) in the dataset.

dataset_cat_as_labels(dataset, data_dict = NULL, col_names = names(dataset))

Arguments

dataset

A dataset object.

data_dict

A list of data frame(s) representing metadata of the input dataset. Automatically generated if not provided.

col_names

A character string specifying the name(s) of the column(s) which refer to existing column(s) in the dataset. The column(s) can be named or indicated by position.

Value

A data frame identifying a dataset.

Details

A dataset is a data table containing variables. A dataset object is a data frame and can be associated with a data dictionary. If no data dictionary is provided with a dataset, a minimum workable data dictionary will be generated as needed within relevant functions. Identifier variable(s) for indexing can be specified by the user. The id values must be non-missing and will be used in functions that require it. If no identifier variable is specified, indexing is handled automatically by the function.

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.

Examples

{

dataset = madshapR_DEMO$dataset_PARIS
data_dict = as_data_dict_mlstr(madshapR_DEMO$data_dict_PARIS)
dataset_cat_as_labels(dataset, data_dict, col_names = 'SEX')

}
#> Processing of : SEX
#> # A tibble: 24 × 7
#>    ID           SEX         BMI   AGE   SMO SMO_QTY PRG_EVER
#>  * <chr>        <chr+lbl> <dbl> <dbl> <dbl>   <dbl>    <dbl>
#>  1 Paris_687393 Femme [1]  22.2    52     1      32        0
#>  2 Paris_585666 Homme [0]  15.2    49     1       8       -8
#>  3 Paris_75802  Homme [0]  22.7    43     1      48       -8
#>  4 Paris_412072 Femme [1]  NA      59     1      11        0
#>  5 Paris_404333 Femme [1]  26.2    40     1      18        1
#>  6 Paris_554985 Homme [0]  16.0    47     1       7       -8
#>  7 Paris_714168 Femme [1]  19.0    46     1      18       NA
#>  8 Paris_145477 Femme [1]  16.9    53     0      -8        1
#>  9 Paris_202076 Femme [1]  29.9    35     1      36        1
#> 10 Paris_847235 Homme [0]  20.6    NA     0      -8       -8
#> # ℹ 14 more rows