tests/testthat/test-tidyr-utils.R

test_that("uncount has the correct result", {
  tit <- use_data_titanic(count = TRUE)
  expect_equal(nrow(uncount_compat(tit, wt = n)), 2201)
  res <- tibble::tribble(~x, ~n,
                  1.2, 1,
                  3.4, 3,
                  1.2, 2,
                  .5, NA,
                  1.2, 0,
                  .5, 0) %>%
    uncount_compat(n)
  expect_equal(nrow(res), 6)
})
rolkra/explore documentation built on April 17, 2024, 10:58 p.m.