[Rd] improved pairs.formula?
Berwin A Turlach
berwin at maths.uwa.edu.au
Tue Mar 29 11:04:06 CEST 2005
>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
BDR> Still not a description, just two examples.
O.k., I believe that I slowly understand want you want. So in my book
a description of "the job" would be: "that it is allowed to use '.' and
'-' in the formula given to pairs thus allowing pairs.formula".
BDR> Since later on you took a description to be an example, I see
BDR> the confusion.
Just to avoid future confusion, so how does one distinguish a
description from an example, especially if the description is after
the phrase "such as"
BDR> and why you chose such an unusual piece of code to do it?
>> Mmh, I don't think of it as being so unusual, most of it was
>> gleaned from other R function. Well, I realise that R
>> programing paradigms change over the years, so I must have
>> gotten them from quite old routine.
BDR> I guess you got it from an S not R function.
Quite possible. Sorry, I can't check since I never had access to S.
BDR> (E.g. what is the prescription for the ordering of terms, and
BDR> why do you think the rownames of the factors and the
BDR> variables might be in different orders? They are set the
BDR> same in the C code.)
>> In case that a user foolishly specifies a more complicated
>> formula having not read the help pages. It seemed to me that
>> this was the only construct to figure out which variables are
>> actually appearing in terms of the formula.
BDR> Really? Please check what I wrote: `variables' and `rownames
BDR> of the factors' are always the same, apart from the response.
BDR> Please show an example where you got something different.
Sorry, seems to be some misunderstanding here. With 'variables' you
mean the "variables" attribute of the object extracted by "mt <-
attr(mf, "terms")" in my code? It is well possible that this is
always in the same order as the rownames of the factors but I didn't
find that in the documentation and I didn't study the C code to write
this function. But I take your word for it and in this case I can see
how the code could be simplified. Shall I submit a revised version or
BDR> There are several places where only the allowed form of
BDR> formulae is specified in this way.
In this case, may I request that this places are better marked than
they are at the moment?
BDR> You are not allowed interactions, for example, and it refers
BDR> to `each term'.
Indeed, it states "Each term will give a separate variable in the
pairs plot, so terms should be numeric vectors". So some users might
be surprise that the following works:
> dat <- data.frame(x=rnorm(30), y=rnorm(30), f=rep(c("A","B", "C"), 10))
> pairs(~x+y+f, dat)
Who, but the most arduous student of R help page language would have
thought that dat$f is a numeric vector? :-))
BDR> `.' is not documented to work (and used not to).
So the question is whether it should remain this way or not. But that
is for the R core team to decide and I shall stop my contributions to
this thread now.
========================== Full address ============================
Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr)
School of Mathematics and Statistics +61 (8) 6488 3383 (self)
The University of Western Australia FAX : +61 (8) 6488 1028
35 Stirling Highway
Crawley WA 6009 e-mail: berwin at maths.uwa.edu.au
More information about the R-devel