tests/testthat/test-subsetting.R

## Test subsetting methods `[`

## load packages
library("testthat")
library("mgcv")
library("gratia")

test_that("subsetting works for smooth_samples", {
    sm <- smooth_samples(m_gam, seed = 42)
    hsm <- head(sm)
    expect_identical(NROW(hsm), 6L)
    expect_true(! is.null(attr(hsm, "seed")))

    attrs <- attributes(hsm)
    expect_type(attrs, "list")
    expect_named(attrs, expected = c("names", "row.names", "class", "seed"))
})

Try the gratia package in your browser

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

gratia documentation built on Feb. 16, 2023, 10:40 p.m.