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

From: Richard M. Heiberger <rmh_at_temple.edu>
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



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.