[R] a very easy question, how to extract the name of the response variable
Eric R.
ericr at mcs.st-and.ac.uk
Tue Nov 13 11:01:40 CET 2007
This may not be the smoothest way to produce the result, but here is a
two-step solution:
first find the formula within the object created by the call to glm():
form <- qq["formula"] or equivalently form <- qq$formula
then apply the function all.vars() to the result, and return the first
element
variables.in.formula <- all.vars(form)
variables.in.formula[1] # will be the response variable
leffgh wrote:
>
> for example
> glm(a~b+c+d,data=eee)->qq
>
> Is there a function able to return the name of the response variable?
> suppose "ff" is the function satisfying this need,
> ff(qq) then "a" (Not the value of a) will be returned.
> could you tell me which is the "ff" I am looking for ?
>
> Thank you very much
>
>
--
View this message in context: http://www.nabble.com/a-very-easy-question%2C-how-to-extract-the-name-of-the-response-variable-tf4796264.html#a13722941
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list