[Rd] termplot fails for composite non-factor terms (PR#828)
Sat, 27 Jan 2001 01:57:38 +0100 (MET)
I am running R 1.2.1 under Windows 98SE.
termplot() currently fails when there are composite terms, thus:
> hills.lm <- lm(time ~ climb + poly(dist, 2), data = hills)
Hit <Return> to see next plot:
Error in eval(expr, envir, enclos) : Object "dist" not found
does run without generating an error message, i.e. there is a
problem with the default setting for the parameter 'data'.
However the x-axis for the term poly(dist,2) is then incorrectly
labelled as poly(dist,2), rather than dist
The label poly(dist,2) surely belongs as part of the y-axis label.
Here are suggested fixes
1. In the default parameters for the function call change
data = model.frame(model)
data = get(as.character(model$call$data))
[This does not work if the variable values are specified in the
function call. It is not clear to me how to fix that.]
2. A few lines from the beginning, replace
xlabs <- nmt
ylab <- substitute(link(foo), list(foo = formula(model)[]))
xlabs <- unlist(lapply(cn,function(x)
if(length(x)>1)as.character(x[]) else as.character(x)))
ylab <- paste("Partial for", nmt)
[The current y-label is "link(<yvar>)". If it is thought necessary
to specify this, it should be additional to e.g., in my example,
"Partial for poly(dist,2)"]
Replace ylab = ylab with
ylab = ylab[i]
in the two places (arguments to plot()) where it appears.
John Maindonald email : firstname.lastname@example.org
Statistical Consulting Unit, phone : (6125)3998
c/o CMA, SMS, fax : (6125)5549
John Dedman Mathematical Sciences Building
Australian National University
Canberra ACT 0200
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: email@example.com