Jorge Ivan Velez wrote:
> Hi Esmail,
>
> Try this:
>
> vars=c('X.1', 'X.2', 'X.3', 'X.4', 'X.5')
> bits=c(1, 0, 1, 1, 0)
> paste(vars[which(bits==1)],collapse="+")
>
> HTH,
>
> Jorge
Wow .. that is beautiful :-) .. and exactly what I was looking for (and suspected existed).
I ended up doing this:
eqn=(paste(vars[which(bits==1)],collapse=" + "))
eqn=paste(c("Y.data ~"), eqn)
GLM.9 <- glm(as.formula(eqn) , family=gaussian(identity), data=simpleData)
For some reason I couldn't collapse the two eqn/paste statements into one statement but this seems to work.
Thank again Jorge and everyone else .. this group is a big help.
Esmail
Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.
Archive generated by hypermail 2.2.0, at Tue 06 May 2008 - 20:30:43 GMT.
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.