Re: [R] dot in formula

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 03 Jun 2005 - 18:36:42 EST

On Fri, 3 Jun 2005, Bjørn-Helge Mevik wrote:

> Adrian Baddeley writes:
>
>> I want to manipulate a formula object, containing the name "."
>> so that "." is replaced by a desired (arbitrary) expression.
>
> How about
>
> myf <- y ~ .
> update(myf, . ~ -. + X)

or just update(myf, . ~ X). Here "." is not being treated literally (nor can it be in the internal formula manipulation code).

If you just want to replace a rhs `.' then there are easier ways, e.g.

> myf <- y ~ .
> myf[[3]] <- quote(X)
> myf

y ~ X

However, I think Adrian might want something like

> myf <- y ~ a + . + x
> update(myf, . ~ -. + X)
y ~ X

I think the best way to do that is by substitute(), e.g.

> substitute(y ~ a + . + x, list("."=quote(X)))
y ~ a + X + x

If that is not enough ideas, perhaps Adrian could give us an example?

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Received on Fri Jun 03 18:40:05 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:22 EST