[R] using lm() with variable formula

Richard M. Heiberger rmh at temple.edu
Thu May 17 17:37:06 CEST 2007


> tmp <- data.frame(matrix(rnorm(40),10,4, dimnames=list(NULL, c("Y","A","B","C"))))
> tmp
> tmp.form <-  paste(names(tmp)[1], paste(names(tmp)[-1], collapse=" + "), sep=" ~ ")
> tmp.form
> lm(tmp.form, tmp)

The R language is powerful enough to most of the lisp-like things
you may want to do.

Rich



More information about the R-help mailing list