tests/testthat/helper-data.R

# Produces different versions of mmrm_test_data.
get_version <- function(version = c("A", "B")) {
  version <- match.arg(version)
  set.seed(123, kind = "Mersenne-Twister") # Because of `sample` below.
  # nolint start
  mmrm_test_data %>%
    droplevels() %>%
    {
      if (version == "B") {
        dplyr::mutate(
          .,
          # Introduce extra missing response variable values.
          FEV1 = ifelse(
            sample(c(TRUE, FALSE), size = length(FEV1), replace = TRUE, prob = c(0.1, 0.9)),
            NA,
            FEV1
          ),
          # And also covariate values.
          FEV1_BL = ifelse(
            sample(c(TRUE, FALSE), size = length(FEV1_BL), replace = TRUE, prob = c(0.1, 0.9)),
            NA,
            FEV1_BL
          )
        )
      } else {
        # No further changes in version A.
        .
      }
    }
  # nolint end
}

Try the tern.mmrm package in your browser

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

tern.mmrm documentation built on June 22, 2024, 9:38 a.m.