Arnab mukherji wrote:
Hi,

I have a query about the following:

CONTEXT: if we define:

eq <- y ~ x1 + x2

then is.language(eq) returns true. this works perfectly with commands
such as lm(eq,data=my.data)

THE PROBLEM: Now I have a big data set with about 2000 independent
variables. So I tried to automate this. I can pick off the names of
the variables and insert a plus in between them and get a string.
Thus I have

eq<- y ~ " x1 + x2 + ... +x2000" or eq<-"y ~ " x1 + x2 + ... +x2000"

from either case how can I typecast eq into a langugae object and get
the lm command to work ?

Does anyone have any suggestions?

thanks

Arnab.

Arnab,

Once you have your full formula string constructed you can use:

eq <- eval(parse(text = string))

This will put the model formula into eq.


For example try:

eq <- eval(parse(text = "y ~ x1 + x2"))


See ?eval and ?parse for more information.

Hope that helps.


Regards,

Marc Schwartz

______________________________________________
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to