Is there an appropriate way to do R style logistic regression where I avoid using loops, but I can have multiple regressions for each level in a particular factor?
For example, assume df is 365 daily rows with a binary to say whether or not it rained:
multifactorglm(x){
glm(rained ~ temp + humidity, data=x, family="binomial")
}
tapply(df, month, multifactorglm)
This won't run in R with the following message...
Error: unexpected '{' in "multifactorglm(x){"
> glm(rained ~ temp + humidity, data=x, family="binomial")
Error in eval(predvars, data, env) :
numeric 'envir' arg not of length one
> }
Error: unexpected '}' in "}"
>
I would like to have as a result a vector of 12 glm regressions, but I don't want to use a loop. What do I do?