tests/testthat/test-label-dictionary.R

test_that("label_dictionary gives correct answers", {
  short <- c("A", "B", "C")
  lut <- c("A" = "Apple", "C" = "Cherry", "D" = "Date")

  expect_equal(label_dictionary(lut)(short), c("Apple", "B", "Cherry"))
  expect_equal(
    label_dictionary(lut, nomatch = "Banana")(short),
    c("Apple", "Banana", "Cherry")
  )
})

Try the scales package in your browser

Any scripts or data that you put into this service are public.

scales documentation built on June 8, 2025, 12:13 p.m.