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)
})

Try the explore package in your browser

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

explore documentation built on Oct. 11, 2023, 9:07 a.m.