tests/testthat/test-preprocess-sum.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"),
      replace_with_sum = "value"
    )
  )

  preprocessed <- preprocess_table(df, mock_preproc_spec)
  alternative <- df %>%
    group_by(id, group) %>%
    mutate(value = sum(value)) %>%
    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.