Re: [R-sig-Geo] Predict gam in a loop on multiple raster stacks and keeping identical layer names

2015-05-06 Thread Kristin
Thank you very much for the help Robert! Works wonders. -Such a simple addition to the loop to fix the naming of layers :). This raster package is so brilliant. atb, Kristin -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/Predict-gam-in-a-loop-on-multiple-raster-stack

Re: [R-sig-Geo] Predict gam in a loop on multiple raster stacks and keeping identical layer names

2015-05-05 Thread Robert J. Hijmans
Kristin, I think you can do something like this: lst <- list() for(i in 1:96) { Predictors <- stack(stackchl[[i]], stacksst[[i]], stackpar[[i]], lat, lon) names(Predictos) <- c('chl', 'sst', 'par', 'lat', 'lon') lst[[i]] <- predict(Predictors, gammodel, na.rm=TRUE, type="response") } s <-

[R-sig-Geo] Predict gam in a loop on multiple raster stacks and keeping identical layer names

2015-05-05 Thread Kristin
I have a gam model with predictor names (variables) par, chl, sst, lat and lon. The model I called "gammodel". Then I have predictors for 96 day period in raster stacks: "stackpar", "stackchl", "stacksst" -that is 3 different raster stacks - each one with 96 layers. lat and lon are fixed in time