use as.formula() rather than just formula(). 

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of john seers (IFR)
Sent: Friday, 1 February 2008 7:31 PM
To: [EMAIL PROTECTED]
Subject: [R] Building a formula using paste


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@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.

______________________________________________
R-help@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.

Reply via email to