[R] replacing characters in formulae / models

From: Christoph Scherber <Christoph.Scherber_at_agr.uni-goettingen.de>
Date: Thu, 06 Nov 2008 16:50:52 +0100


Dear all,

How can I replace text in objects that are of class "formula"?

y="a * x + b"
class(y)="formula"
grep("x",y)
y[1]

Suppose I would like to replace the "x" by "w" in the formula object "y".

How can this be done? Somehow, the methods that can be used in character objects do not work 1:1 in formula objects...

Many thanks and best wishes
Christoph

-- 
Dr. rer.nat. Christoph Scherber
University of Goettingen
DNPW, Agroecology
Waldweg 26
D-37073 Goettingen
Germany

phone +49 (0)551 39 8807
fax   +49 (0)551 39 8806

Homepage http://www.gwdg.de/~cscherb1

______________________________________________
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 Thu 06 Nov 2008 - 15:59:35 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 06 Nov 2008 - 17:30:22 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