tests/testthat/test_expncat_stat.R

context("summary statistics for individual categorical predictors")

test_that("test normal function", {
  X <- mtcars$gear
  Y <- mtcars$am
  expect_error(ExpStat(X, Y))
  Y[2] <- NA
  expect_error(ExpStat(X, Y))
})

test_that("test output object", {
  X <- mtcars$gear
  Y <- mtcars$am
  catstat <- ExpStat(X, Y, valueOfGood = 1)
  ctv <- chisq.test(X, Y, simulate.p.value = TRUE)
  ctat <- as.numeric(round(ctv$statistic, 3))
  expect_output(str(catstat), "chr")
  expect_equal(ctat, as.numeric(catstat[2]))
})
?chisq.test

Try the SmartEDA package in your browser

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

SmartEDA documentation built on Dec. 4, 2022, 1:15 a.m.