tests/testthat/test-methods.R

fit <- lm(Sepal.Length ~ ., data = iris)
xvars <- colnames(iris)[-1]
M <- feature_effects(fit, v = xvars, data = iris, y = "Sepal.Length", breaks = 5)

test_that("subsetting and concatenating works", {
  # The test uses the fact that for smallish data, no seeding is needed
  M1 <- feature_effects(
    fit, v = xvars[1:2], data = iris, y = "Sepal.Length", breaks = 5
  )
  M2 <- feature_effects(
    fit, v = xvars[3:4], data = iris, y = "Sepal.Length", breaks = 5
  )

  expect_equal(M, c(M1, M2))
  expect_equal(M[3:4], M2)
})

test_that("print() gives no error", {
  capture_output(expect_no_error(print(M)))
  capture_output(expect_no_error(print(M[3])))
})

test_that("object is of class 'feature_effects'", {
  expect_s3_class(M, "EffectData")
})

Try the effectplots package in your browser

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

effectplots documentation built on April 12, 2025, 2:13 a.m.