Internal helper. Given the model data and a fitted gam object, returns a tibble with one row per smooth curve to be drawn by get_terms / gg_smooth. Only smooths that vary over exactly one numeric covariate are returned. This includes ordinary 1d smooths (s(), 1d ti()), by-variable smooths (s(x, by = z)) and factor-smooth interactions (s(x, fac, bs = "fs"), s(x, fac, bs = "sz")). Tensor and multivariate smooths (te(), t2(), 2d ti(), s(x, z)) as well as (correlated) random effects (bs = "re", bs = "mrf") are excluded – use gg_tensor / gg_re for those.

get_smooth_terms(data, fit)

Arguments

data

A data frame containing the variables used to fit the model.

fit

A fitted model object.

Value

A tibble with columns facet, level, var, col and the list-column settings, or NULL.

Details

Smooths that are indexed by a factor (a factor by-variable or the factor in an fs/sz interaction) are expanded into one row per factor level, all sharing the same facet so that gg_smooth can draw them in a single panel, distinguished by colour/fill.

Returns NULL for models without a $smooth component (e.g. coxph), in which case get_terms falls back to label-based extraction.