[Rd] should delete.response(response~predictor) return ~predictor?
wdunlap at tibco.com
Fri Sep 21 19:57:02 CEST 2012
I noticed the delete.response() just returns its input if the input
is not of class "terms". Hence we get surprising (to me) results like
> env <- new.env()
> env # formulae have an environment, calls do not
> with(env, delete.response(y ~ x1 + x2)) # class "formula"
y ~ x1 + x2
> with(env, delete.response(quote(y ~ x1 + x2))) # class "call" (to `~`)
y ~ x1 + x2
Without reading the help file, I would have expected ~x1+x2, as in
> with(env, formula(delete.response(terms(y ~ x1 + x2))))
~x1 + x2
survey:::summary.svytable (ver. 3.28-2) seems to expect delete.response
to work on calls, as it calls delete.response() on the call object which is
the "formula" argument in the "call" attribute of its input.
function (object, statistic = c("F", "Chisq", "Wald", "adjWald",
"lincom", "saddlepoint"), ...)
statistic <- match.arg(statistic)
call <- attr(object, "call")
ff <- call$formula
env <- parent.frame()
else env <- environment(ff)
ff <- delete.response(ff)
(Perhaps it was intended to get a real formula or terms object here, as the
environment of a call is NULL, unless the user attached the ".Environment"
If delete.response doesn't do anything with non-terms objects, should it
throw an error if it is given such a thing?
Spotfire, TIBCO Software
More information about the R-devel