tests/testthat/test-as.data.frame.R

skip_if_not_installed("marginaleffects", minimum_version = "0.29.0")

test_that("as.data.frame.estimate_contrasts()", {
  data(iris)
  model <- lm(Petal.Length ~ Species, data = iris)
  estim <- estimate_means(model, "Species")
  out <- as.data.frame(estim, preserve_names = FALSE)
  expect_named(out, c("Species", "Coefficient", "SE", "CI_low", "CI_high", "t", "df"))
  out <- as.data.frame(estim, preserve_names = FALSE, use_responsename = TRUE)
  expect_named(out, c("Species", "Petal.Length", "SE", "CI_low", "CI_high", "t", "df"))
  out <- as.data.frame(estim, preserve_names = TRUE)
  expect_named(out, c("Species", "Mean", "SE", "CI_low", "CI_high", "t", "df"))
})

Try the modelbased package in your browser

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

modelbased documentation built on Dec. 8, 2025, 5:13 p.m.