Skip to content
Prev 333023 / 398506 Next

Loop through columns of outcomes

Hello,

Use nested lapply(). Like this:



m1 <- lapply(varlist0,function(v) {
	lapply(outcomes, function(o){
		f <- sprintf("%s~ s(time,bs='cr',k=200)+s(temp,bs='cr') + 
Lag(%s,0:6)", o, v)
		gam(as.formula(f),family=quasipoisson,na.action=na.omit,data=df)
       })})

m1 <- unlist(m1, recursive = FALSE)
m1


Hope this helps,

Rui Barradas


Em 12-11-2013 09:53, Kuma Raj escreveu: