[R] as.character and a formula

Gavin Simpson gavin.simpson at ucl.ac.uk
Tue Aug 16 20:04:36 CEST 2005


Dear list,

given this formula: 

> fmla <- formula(y1 ~ spp1 + spp2 + spp3 + spp5)
> fmla[[3]]
spp1 + spp2 + spp3 + spp5

is this the intended behaviour of as.character:

> as.character(fmla[[3]])
[1] "+"                  "spp1 + spp2 + spp3" "spp5"

? Where does the extra "+" come from?

> as.character(fmla)
[1] "~"                         "y1"                       
[3] "spp1 + spp2 + spp3 + spp5"

Thanks in advance,

Gav
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Gavin Simpson                     [T] +44 (0)20 7679 5522
ENSIS Research Fellow             [F] +44 (0)20 7679 7565
ENSIS Ltd. & ECRC                 [E] gavin.simpsonATNOSPAMucl.ac.uk
UCL Department of Geography       [W] http://www.ucl.ac.uk/~ucfagls/cv/
26 Bedford Way                    [W] http://www.ucl.ac.uk/~ucfagls/
London.  WC1H 0AP.
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list