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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to