R/03-dataset_functions.R
dataset_cat_as_labels.Rd
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))
A dataset object.
A list of data frame(s) representing metadata of the input dataset. Automatically generated if not provided.
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.
A data frame identifying a dataset.
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
.
{
dataset = madshapR_examples$`dataset_example`
data_dict = as_data_dict_mlstr(madshapR_examples$`data_dictionary_example`)
dataset_cat_as_labels(dataset, data_dict, col_names = 'gndr')
}
#> Processing of : gndr
#> # A tibble: 50 × 9
#> part_id gndr height weight_ms weight_dc dob prg_ever empty opentext
#> * <chr> <chr+lbl> <dbl> <dbl> <dbl> <chr> <dbl> <lgl> <chr>
#> 1 ID001 Male [1] 191 63 NA 3/22… -7 NA All chi…
#> 2 ID002 Female [2] 176 NA 65 8/15… 0 NA grow up…
#> 3 ID003 Female [2] 154 NA 121 12/1… 2 NA years o…
#> 4 ID004 Female [2] 167 -88 NA 6/13… 1 NA flower …
#> 5 ID005 Female [2] 185 NA 45 12/1… 8 NA rather …
#> 6 ID006 Don’t… [-77] 171 57 NA 3/31… -7 NA cried, …
#> 7 ID007 Female [2] 185 NA 58 4/19… 9 NA that pa…
#> 8 ID008 Female [2] 171 NA 59 NA 2 NA that sh…
#> 9 ID009 Don’t… [-77] 169 52 NA 3/14… -7 NA beginni…
#> 10 ID010 Male [1] 179 NA 62 10/1… -7 NA All chi…
#> # ℹ 40 more rows