tests/testthat/test_expcustomstat.R

context("Customized summary statistics")

test_that("test normal function", {
  df <- iris
  xyz <- df$Sepal.Length
  expect_error(ExpCustomStat(xyz, Cvar = "am", Nvar = "mpg"))
  expect_error(ExpCustomStat(mtcars))
  expect_error(ExpCustomStat(mtcars, Cvar = "am", Nvar = "mpg"))
  expect_error(ExpCustomStat(mtcars, Nvar = "mpg", gpby = FALSE))
})

test_that("test output object", {
  catstat <- ExpCustomStat(mtcars, Cvar = "am", Nvar = "mpg", stat = "mean")
  str(catstat)
  expect_output(str(catstat), "data.frame")
  expect_output(str(catstat), "2 obs")
  catstat1 <- ExpCustomStat(mtcars, Nvar = "mpg", stat = "mean")
  expect_equal(catstat1$mean, mean(mtcars$mpg))
})

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.