tests/testthat/test-data-preprocessing.R

# Load data and preprocess
# Relative path from the testthat folder
data(pedis)
vars <- c("p", "e")
X_y <- prepare_X_y(data = pedis, outcome = "minor_amputation", vars = vars)
X <- X_y[[1]]
y <- X_y[[2]]

test_that("Data preprocessing is correct", {
  testthat::expect_true(is.data.frame(pedis))
  testthat::expect_true(is.factor(y))
  testthat::expect_true(is.matrix(X))
  testthat::expect_identical(length(vars), ncol(X))
})
jnshsrs/PEDISdata documentation built on June 24, 2019, 12:07 p.m.