Re: [R] building a formula string bit by bit ..

2008-05-06 Thread Esmail Bonakdarian
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

Re: [R] building a formula string bit by bit ..

2008-05-06 Thread Marc Schwartz
Marc Schwartz wrote: Esmail Bonakdarian wrote: Hello, Still a newbie with R, though I have learned a lot from reading this list. I'm hoping someone can help with this question: I have two vectors, one for variables, and one for bits. I want to build a string (really a formula) based on the va

Re: [R] building a formula string bit by bit ..

2008-05-06 Thread Charilaos Skiadas
I would actually go with this: bits=c(1, 0, 1, 1, 0) paste("X", which(bits==1), sep=".",collapse="+") No need for the vars variable. Though admittedly it breaks down if bits is identically 0. Haris Skiadas Department of Mathematics and Computer Science Hanover College On May 6, 2008, at 3:1

Re: [R] building a formula string bit by bit ..

2008-05-06 Thread Marc Schwartz
Esmail Bonakdarian wrote: Hello, Still a newbie with R, though I have learned a lot from reading this list. I'm hoping someone can help with this question: I have two vectors, one for variables, and one for bits. I want to build a string (really a formula) based on the values in my vector of 1

Re: [R] building a formula string bit by bit ..

2008-05-06 Thread Jorge Ivan Velez
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 On Tue, May 6, 2008 at 3:06 PM, Esmail Bonakdarian <[EMAIL PROTECTED]> wrote: > Hello, > > Still a newbie with R, though I have learned a lot from reading

[R] building a formula string bit by bit ..

2008-05-06 Thread Esmail Bonakdarian
Hello, Still a newbie with R, though I have learned a lot from reading this list. I'm hoping someone can help with this question: I have two vectors, one for variables, and one for bits. I want to build a string (really a formula) based on the values in my vector of 1s and 0s in bits. If I have