Re: [R] using lm() with variable formula

From: Richard M. Heiberger <>
Date: Thu, 17 May 2007 11:37:06 -0400 (EDT)

> 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 mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Thu 17 May 2007 - 15:53:21 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 May 2007 - 16:30:54 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.