Learn R Programming

codelist (version 0.1.0)

in_labels: Match codes based on label

Description

Match codes based on label

Usage

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

Value

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

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.

Examples

Run this code
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")))

Run the code above in your browser using DataLab