tests/testthat/test_na_locf.r

vec <- c(1, NA, NA, NA, 3, NA, NA, 4, NA, 6)
true_filled <- c(1, 1, 1, 1, 3, 3, 3, 4, 4, 6)

test_that("example case working", {
  filled <- na_locf(vec)
  expect_equal(filled, true_filled)
})

test_that("works with no missings", {
  expect_equal(na_locf(true_filled), true_filled)
})

test_that("works with empty vector", {
  filled <- na_locf(numeric(0))
  expect_equal(filled, numeric(0))
})

Try the simDAG package in your browser

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

simDAG documentation built on April 3, 2025, 10:35 p.m.