tests/testthat/test-adjust_frm.R

library(testthat)

test_that("adjust_frm works", {
    opts <- options(FastRet.mocks = c("train_frm"))
    on.exit(options(opts), add = TRUE)
    frm = train_frm(verbose = 0)
    new_data = read_rpadj_xlsx()
    m12 <- adjust_frm(frm, new_data, predictors = 1:2)
    m1to6 <- adjust_frm(frm, new_data, predictors = 1:6)
    expect_identical(
        object = names(coef(m12$adj$model)),
        expected = c("(Intercept)", "RT", "I(RT^2)")
    )
    expect_identical(
        object = names(coef(m1to6$adj$model)),
        expected = c("(Intercept)", "RT", "I(RT^2)", "I(RT^3)", "log(RT)", "exp(RT)", "sqrt(RT)")
    )
    expect_error(
        object = adjust_frm(frm, new_data, predictors = c()),
        regexp = ".*Invalid predictors.*"
    )
})

Try the FastRet package in your browser

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

FastRet documentation built on June 25, 2024, 5:07 p.m.