has_quant_labs {labelr}R Documentation

Is this an add_quant_labs()-style Value-labeled Variable (Column)?

Description

Determine whether a specific variable of a data.frame has value labels associated with it that were added using add_quant_labs() or add_quant1().

Usage

has_quant_labs(data, var)

Arguments

data

a data.frame.

var

the unquoted name of the variable (column) to check for the presence of add_quant_labs()-style numerical range-based value labels.

Details

hql is a compact alias for has_quant_labs: they do the same thing, and the former is easier to type

Value

A 1L logical.

Examples

# copy mtcars to mt2 and assign various types of value labels
mt2 <- mtcars

# add 1-to-1 value labels
mt2 <- add_val_labs(
  data = mt2,
  vars = "am",
  vals = c(0, 1),
  labs = c("automatic", "manual")
)

has_val_labs(mt2, am) # TRUE, it does
has_m1_labs(mt2, am) # FALSE, they are NOT add_m1_lab()-style
has_quant_labs(mt2, am) # FALSE, they are NOT add_quant_labs() -style

# add many-to-1 value labels
mt2 <- add_m1_lab(
  data = mt2,
  vars = "gear",
  vals = 4:5,
  lab = "4+"
)

has_val_labs(mt2, gear) # TRUE, it does
has_m1_labs(mt2, gear) # TRUE, they ARE add_m1_lab()-style
has_quant_labs(mt2, gear) # FALSE, they NOT not add_quant_labs() -style

# add quartile-based numerical range value labels
mt2 <- add_quant_labs(
  data = mt2,
  vars = "disp",
  qtiles = 4
)

has_val_labs(mt2, disp) # TRUE, it does
has_m1_labs(mt2, disp) # FALSE, they are NOT add_m1_lab()-style
has_quant_labs(mt2, disp) # TRUE, they ARE add_quant_labs() -style

[Package labelr version 0.1.5 Index]