tests/testthat/test-lag_lead.R

test_that("lag and lead", {
  expect_equal(
    lead_dt(1:5),
    shift(1:5,type = "lead")
  )
  expect_equal(
    lag_dt(1:5),
    shift(1:5,type = "lag")
  )
  expect_equal(
    lag_dt(1:5,n = 2),
    shift(1:5,n = 2,type = "lag")
  )
  expect_equal(
    lead_dt(1:5,n = 2,fill = 0),
    shift(1:5,n = 2,type = "lead",fill = 0)
  )
})
hope-data-science/tidyfst documentation built on Sept. 23, 2024, 8:05 p.m.