[R] Building a formula using paste

john seers (IFR) john.seers at bbsrc.ac.uk
Fri Feb 1 10:31:14 CET 2008


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
> 




 
---



More information about the R-help mailing list