tests/testthat/test-arrange_dt.R

test_that("arrange a data.frame", {

  ir = as.data.table(iris)

  expect_equal(iris %>% arrange_dt(Sepal.Length),ir[order(Sepal.Length)])

  expect_equal(iris %>% arrange_dt(-Sepal.Length),ir[order(-Sepal.Length)])

  expect_equal(iris %>% arrange_dt(Sepal.Length,Petal.Length),
               ir[order(Sepal.Length,Petal.Length)])

  expect_equal(iris %>% arrange_dt(Sepal.Length,-Petal.Length),
               ir[order(Sepal.Length,-Petal.Length)])
})

Try the tidyfst package in your browser

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

tidyfst documentation built on Sept. 16, 2024, 9:06 a.m.