Binding dictionaries together can be useful when you have variables that exist in multiple datasets and you don't want to re-write their meta information into each of those datasets.
Usage
bind_dictionary(
...,
.list = NULL,
conflict_preference = "left",
drop_unmatched_variables = FALSE
)
left_bind(..., .list = NULL, drop_unmatched_variables = FALSE)
right_bind(..., .list = NULL, drop_unmatched_variables = FALSE)Arguments
- ...
Data dictionary objects to combine.
- .list
This argument allows
bind_dictionaryto be used programmatically and is optional. It is intended to be used as an alternative to..... Specifically, instead ofbind_dictionary(x, y), you can usebind_dictionary(.list = list(x, y)). This is helpful when you have a lot of dictionaries and want to bind them programmatically.- conflict_preference
a character value indicating what to do when
xandyhave overlapping variables. If "left", then the definitions in thexdictionary are preferred becausexis on the left ofyin the function arguments. If "right",ydefinitions are preferred.- drop_unmatched_variables
logical. If
TRUE, variables inythat are not inxwill be retained in the output. IfFALSE(default), only variables fromxand those inythat overlap withxwill be included, subject toconflict_preference.
Value
A data dictionary object
Examples
dd_age_years <- data_dictionary(
numeric_variable(
name = "age_years",
label = "Age",
units = 'years',
divby_modeling = 10
)
)
dd_age_group <- data_dictionary(
nominal_variable(
name = "age_group",
label = "Age group",
description = "Ages of 0 to < 50, 50 to < 60, and \u2265 60 years",
category_levels = c("age_lt_50", "age_gteq_50_lt_60", "age_gteq_60"),
category_labels = c("0 to < 50", "50 to < 60", "\u2265 60")
)
)
bind_dictionary(dd_age_years, dd_age_group)
#> Data Dictionary:
#> # A tibble: 2 × 8
#> name type label description units divby_modeling category_levels
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 age_years Numeric Age none years 10 none
#> 2 age_group Nominal Age group Ages of 0 to… none none age_lt_50, age…
#> # ℹ 1 more variable: category_labels <chr>
