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)
Run the code above in your browser using DataLab