Skip to contents

Replace coded values in a brreg tibble with English descriptions, following the eurostat package's label_eurostat() pattern. Works on both data frames and character vectors.

Usage

brreg_label(x, dic = NULL, code = NULL, lang = "en")

Arguments

x

A tibble from brreg_entity(), brreg_search(), or brreg_roles(), or a character vector of codes.

dic

A character string naming the dictionary to use when x is a character vector. One of "legal_form", "nace", "sector", "role", "role_group". Ignored when x is a data frame (dictionaries are inferred from column names).

code

For data frames: character vector of column names for which to retain the original code alongside the label. A column with suffix _code is added. For example, brreg_label(x, code = "legal_form") adds legal_form_code.

lang

Language for NACE and sector labels. "en" (default) or "no" (Norwegian original from brreg API).

Value

When x is a data frame: the same tibble with code columns replaced by English labels. When x is a character vector: a character vector of labels.

See also

legal_forms, role_types, role_groups for bundled reference data, get_brreg_dic() for fetching fresh dictionaries.

Other tidybrreg utilities: brreg_validate(), get_brreg_dic()

Examples

if (FALSE) { # interactive() && curl::has_internet()
eq <- brreg_entity("923609016")

# Label all code columns
brreg_label(eq)

# Keep original codes alongside labels
brreg_label(eq, code = "legal_form")

# Label a character vector directly
brreg_label(c("AS", "ASA", "ENK"), dic = "legal_form")
}