Re: [R] Dots in models formulae

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Wed 17 Aug 2005 - 03:48:27 EST

On Tue, 16 Aug 2005, Sundar Dorai-Raj wrote:

> Uwe Ligges wrote:
>> Laurent Valdes wrote:
>>
>>
>>> I have seen, several times, dots (like this: "y ~." ) in formula
>>> descriptions, noticeably in R help.
>>>
>>> I am unable to see what it does correspond to.
>>>
>>> Any ideas ?
>>
>> All other variables (except y) from the given data.frame...
>>
>> Uwe Ligges
>>
>
> Hi, Uwe,
>
> Doesn't this depend on the context? For example,
>
> z <- data.frame(y = rnorm(10), x = rnorm(10))
> fit <- lm(y ~ ., z)
> update(fit, y ~ . + I(x^2))
>
> The original poster did not say where he saw this formula. However, I
> think the reference in ?formula has the most authorative explanation.

(It does not cover this, as it is part of the interpretation of a formula.)

Yes, it must depend on context, as an R function can do anything it likes with a formula (including making y ~ x mean the regression of x on y).

If terms.formula() is used, y ~ . means what Uwe said, _if_ there is a 'data' argument. However, if not it has its literal meaning (a variable named '.'), at least until 2.2.0.

-- 
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 Wed Aug 17 03:54:07 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 15:23:54 EST