tests/testthat/test-preprocess.R

test_that("preprocess_table", {
  df <- read_one_table("../data/preproc.csv")

  # Because preprocess_table() requires a spec rather than taking keyword
  # arguments, we have to make a fake one here
  mock_preproc_spec <- list(
    grouping_column = "id",
    preprocess = list(
      on = c("id", "group"),
      retain_min = "start_date",
      retain_max = "end_date"
    )
  )

  preprocessed <- preprocess_table(df, mock_preproc_spec)
  alternative <- df %>%
    group_by(id, group) %>%
    mutate(start_date = min(start_date)) %>%
    mutate(end_date = max(end_date)) %>%
    ungroup()

  expect_equal(preprocessed, alternative)
})

Try the eider package in your browser

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

eider documentation built on May 29, 2024, 7:27 a.m.