tests/testthat/test_freq_out.R

context("Make a frequency table for a factor")

test_that("expectation for success", {

  cars_tibble <- freq_out(factor(mtcars$cyl))
  iris_tibble <- freq_out(factor(iris$Species))

  expect_equal(cars_tibble$n, c(11,7,14))
  expect_equal(iris_tibble$n, c(50,50,50))
})

test_that("Does it create accurate frequencies", {

  #ERROR - not a factor
  expect_error(freq_out(mtcars))
})
Tangjiahui26/foofactors documentation built on May 18, 2019, 8:11 p.m.