[R] Extracting formula from an lm object

Murray Jorgensen maj at stats.waikato.ac.nz
Sun Aug 24 08:34:39 CEST 2008


I want to extra the part of the formula not including the response
variable from an lm object. For example if the lm object ABx.lm was
created by the call

ABx.lm <- lm( y ~ A + B + x, ...)

Then ACx.lm is saved as part of a workspace.
I wish to extract   "~ A + B + x".  Later in my code I will fit another
linear model of the form z ~ A + B + x for some other response variable z.
I would be grateful for any suggestions of a nice way to do this.

Cheers,  Murray Jorgensen

-- 
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj at waikato.ac.nz    majorgensen at ihug.co.nz      Fax 7 838 4155
Phone  +64 7 838 4773 wk    Home +64 7 825 0441    Mobile 021 139 5862



More information about the R-help mailing list