Skip to content
Prev 256345 / 398502 Next

glm with multiple vars

On 11-04-09 10:34, dirknbr wrote:

            
Hi, you could try to generate the formula as a character string 
and then coerce it into a formula object, since glm expects a 
formula object:

vars <- names(x)
f <- as.formula(paste(vars[1], "~", paste(vars[-1], collapse="+"), 
collapse=""))
glm(f, data=x)

Of course, the pastes in the f-line need to be adjusted in each 
loop.

HTH, *S*