Is there an R data structure into which I can store a number of lm or lmer or gam objects? J has boxed arrays, and one c
Use [[ to access the list elements:
library(mgcv)
set.seed(0) ## simulate some data...
dat <- gamSim(1,n=400,dist="normal",scale=2)
mods <- vector(mode = "list", length = 3)
for(i in seq_along(mods)) {
mods[[i]] <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = dat)
}
Giving:
> str(mods, max = 1)
List of 3
$ :List of 43
..- attr(*, "class")= chr [1:3] "gam" "glm" "lm"
$ :List of 43
..- attr(*, "class")= chr [1:3] "gam" "glm" "lm"
$ :List of 43
..- attr(*, "class")= chr [1:3] "gam" "glm" "lm"