R/metadata.R
list_to_dict.Rd
Sometimes, you'll want to have variable labels in a data.frame, sometimes
you'll have imported an existing data dictionary and will need to turn it
into a list before setting labelled::var_label()
.
list_to_dict(named_list) dict_to_list(dict)
named_list | a named list with one element each (names being variable names, elements being labels) |
---|---|
dict | a data frame with the variable names in the first and the labels in the second column. If they are named variable and label, they can also be in a different order. |
#> $A1 #> NULL #> #> $A2 #> NULL #>dict <- list_to_dict(labels)#> Error: Join columns must be present in data. #> x Problem with `variable`.#> Error in head(dict, 2): object 'dict' not found#> Error: Join columns must be present in data. #> x Problem with `variable`.