tests/testthat/test-target_encoding_loo.R

testthat::test_that("`target_encoding_loo()` works", {
  testthat::skip_on_cran()

  data(vi_smol)

  #rank
  df <- target_encoding_loo(
    df = vi_smol,
    response = "vi_numeric",
    predictor = "soil_type",
    encoded_name = "encoded_column"
  )

  testthat::expect_true(
    class(df[["encoded_column"]]) == "numeric"
  )

  df <- target_encoding_loo(
    df = vi_smol,
    response = "vi_numeric",
    predictor = "soil_type",
    encoded_name = NULL
  )

  testthat::expect_true(
    "soil_type__encoded" %in% colnames(df)
  )
})

Try the collinear package in your browser

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

collinear documentation built on Dec. 8, 2025, 5:06 p.m.