tests/testthat/test-get_group_n.R

library(dplyr)
library(freqtables)

data(mtcars)

testthat::context("test-freq_test.R")

# =============================================================================
# Get sample size for cars with 4 cylinders
# =============================================================================
testthat::test_that("Group n is returned as expected", {
  n <- mtcars %>% get_group_n(cyl == 4)
  testthat::expect_match(n, "N = 11")
})


# =============================================================================
# Clean up
# =============================================================================
rm(mtcars, df)
detach("package:dplyr", unload=TRUE)
detach("package:freqtables", unload=TRUE)

Try the freqtables package in your browser

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

freqtables documentation built on April 3, 2022, 5:11 p.m.