tests/testthat/test-filter_dt.R

test_that("filter a data.frame", {
  ir = as.data.table(iris)

  expect_equal(
    iris %>% filter_dt(Sepal.Length > 7),
    ir[Sepal.Length > 7]
  )

  expect_equal(
    iris %>% filter_dt(Sepal.Length > 7 & Sepal.Width > 3),
    ir[Sepal.Length > 7 & Sepal.Width > 3]
  )

  expect_equal(
    iris %>% filter_dt(Sepal.Length > 7 | Sepal.Width > 3),
    ir[Sepal.Length > 7 | Sepal.Width > 3]
  )

  expect_equal(
    iris %>% filter_dt(Sepal.Length == max(Sepal.Length)),
    ir[Sepal.Length == max(Sepal.Length)]
  )

})

Try the tidyfst package in your browser

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

tidyfst documentation built on July 26, 2023, 5:20 p.m.