[R] Building a formula using paste

From: john seers \(IFR\) <john.seers_at_bbsrc.ac.uk>
Date: Fri, 1 Feb 2008 09:31:14 -0000

Hi All

I have looked but cannot find an answer to this.

I want to build a formula dynamically (in a function), using for example paste, and using it in a model:

	fr<-"F1"	
  	f1<-formula(paste(fr, "~ SensoryTerm"))
  	m1<-aov(f1, data=vdata)

So this is the equivalent of m1<-aov(F1 ~ SensoryTerm, data=vdata)

This works fine but the problem is the formula appears as "f1" in the summary(m1) of the model and not "F1 ~ SensoryTerm". With many models this can be a bit confusing ....

Is there a way to code this so the formula appears in the model summary?

Regards

John Seers

> sessionInfo()

R version 2.6.1 (2007-11-26)
i386-pc-mingw32

locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United
Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252

attached base packages:
[1] stats graphics grDevices datasets utils methods base

other attached packages:
 [1] pixmap_0.4-7 gplots_2.3.2 gdata_2.3.1 gtools_2.4.0 rcom_1.5-2.2
 [6] nnet_7.2-38 e1071_1.5-17 class_7.2-38 tree_1.0-26 mgcv_1.3-29

[11] MASS_7.2-38 car_1.2-7 RODBC_1.2-2 RWinEdt_1.7-9
>
 

---

______________________________________________
R-help_at_r-project.org 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 Fri 01 Feb 2008 - 09:35:20 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 Fri 01 Feb 2008 - 10:30:09 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.

list of date sections of archive