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

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.