[R] How to split the left and right hand terms of a formula

Daniel Gerlanc dgerlanc at gmail.com
Wed Jul 26 21:04:00 CEST 2006


Hello All,

I've sent a few messages to the list regarding splitting a formula
into its right and left hand terms.  Thanks to everyone who has
responded.

I believe that the best way to extract the left and right hand terms
as character vectors follows:

library(nlme)

formula <- y ~ x + z

left.term <- all.vars(getResponseFormula(formula))
covariates <- all.vars(getCovariateFormula(formula))

Thanks!

Dan Gerlanc
Williams College



More information about the R-help mailing list