tests/testthat/test-summary-stats.R

ndata <- dplyr::select(mtcarz, mpg)

test_that("output from ds_summary is as expected when data is a data.frame", {
  
  actual <- round(ds_summary(mtcarz, mpg)$variance, 2)
  expected <- 36.32
  expect_equal(actual, expected)

})

test_that("output from ds_summary is as expected when data is numeric", {
  
  actual <- round(ds_summary(mtcarz$mpg)$variance, 2)
  expected <- 36.32
  expect_equal(actual, expected)

})

test_that("ds_summary_stats throws appropriate errors", {
  fdata <- dplyr::select(mtcarz, cyl, gear, am, vs)
  expect_error(ds_summary_stats(fdata), 'Data has no continuous variables.')
  expect_error(ds_summary_stats(mtcarz, cyl, gear), 'Data has no continuous variables.')
})

Try the descriptr package in your browser

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

descriptr documentation built on April 3, 2025, 8:46 p.m.