load_mgcv()
# \dontshow{
op <- options(pillar.sigfig = 3, cli.unicode = FALSE)
# }
df <- data_sim("eg1", seed = 1)
df <- df[, c("y","x0","x1","x2","x3")]
m <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = "REML")
##
add_fitted(df, m)
## with type = "terms" or "iterms"
add_fitted(df, m, type = "terms")
options(op)
Run the code above in your browser using DataLab