tests/testthat/test-ifelse.R

test_that("ifelse() works", {
  expect_equal(ifelse(1:3 == 2, 4, 5),
               base::ifelse(1:3 == 2, 4, 5))

  tbl_ddf <- dibble(x = 1:3,
                    .dim_names = list(axis = 1:3))
  ddf_col <- tbl_ddf$x
  expect_equal(as.vector(ifelse(tbl_ddf$x == 2, 4, 5)),
               base::ifelse(1:3 == 2, 4, 5))
  expect_equal(as.vector(ifelse(ddf_col == 2, 4, 5)),
               base::ifelse(1:3 == 2, 4, 5))
})

Try the dibble package in your browser

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

dibble documentation built on April 4, 2025, 6:07 a.m.