[R] The curious special case of "~ (a + b)/c"

Nathaniel Smith njs at pobox.com
Sun Jun 6 01:09:30 CEST 2010


On Sat, Jun 5, 2010 at 2:01 PM, RICHARD M. HEIBERGER <rmh at temple.edu> wrote:
> The "/" is used for nesting and is defined by
> A/B == A + (B %in% A)
>
> thus
> (a+b)/c == (a+b) + c %in% (a+b) == a + b + a:b:c

...I guess I could then ask why %in% is defined that way, but actually
this rephrasing somehow helped me figure it out :-). In case anyone
else with the same confusion finds this thread: the point in either
case is that a variable can't be nested in two other variables
separately, so the user must have meant it was nested in both
together.

-- Nathaniel



More information about the R-help mailing list