in_labels: Match codes based on label

View source: R/in_labels.R

in_labelsR Documentation

Match codes based on label

Description

Match codes based on label

Usage

in_labels(
  x,
  labels,
  codelist = attr(x, "codelist"),
  locale = cl_locale(codelist)
)

Arguments

x

vector with codes. Should be of the same type as the codes in the codelist.

labels

vector with labels.

codelist

a codelist object or a data.frame that is a valid code list or and object that has a 'codelist' attribute containing a codelist.

locale

use the codes from the given locale. Should be character vector of length 1.

Value

A logical vector of the same length as x indicating for each value if the code has a label present in labels.

Examples

data(objectcodes)
data(objectsales)
objectsales$product <- code(objectsales$product, objectcodes)

in_labels(objectsales$product, c("Electric Drill", "Toys"))

subset(objectsales, in_labels(product, c("Electric Drill", "Hammer")))


codelist documentation built on April 12, 2025, 2:25 a.m.