smooth_label {gratia} | R Documentation |
Extract the label for a smooth used by 'mgcv'
Description
The label 'mgcv' uses for smooths is useful in many contexts, including
selecting smooths or labelling plots. smooth_label()
extracts this label
from an 'mgcv' smooth object, i.e. an object that inherits from class
"mgcv.smooth"
. These would typically be found in the $smooth
component of
a GAM fitted by mgcv::gam()
or mgcv::bam()
, or related functions.
Usage
smooth_label(object, ...)
## S3 method for class 'gam'
smooth_label(object, id, ...)
## S3 method for class 'mgcv.smooth'
smooth_label(object, ...)
Arguments
object |
an R object. Currently, methods for class |
... |
arguments passed to other methods. |
id |
numeric; the indices of the smooths whose labels are to be extracted. If missing, labels for all smooths in the model are returned. |
Value
A character vector.
Examples
load_mgcv()
df <- data_sim("gwf2", n = 100)
m <- gam(y ~ s(x), data = df, method = "REML")
# extract the smooth
sm <- get_smooths_by_id(m, id = 1)[[1]]
# extract the label
smooth_label(sm)
# or directly on the fitted GAM
smooth_label(m$smooth[[1]])
# or extract labels by idex/position
smooth_label(m, id = 1)
[Package gratia version 0.9.2 Index]