[Rd] Evaluation without using the parent frame
Terry Therneau
therneau at mayo.edu
Wed May 16 22:59:56 CEST 2012
I've been tracking down a survival problem from R-help today. A short
version of the primary issue is reconstructed by the following simple
example:
library(survival)
attach(lung)
fit <- coxph(Surv(time, status) ~ log(age))
predict(fit, newdata=data.frame(abe=45))
Note the typo in the last line of "abe" instead of "age". Instead of an
error message, this returns predictions for all the subjects since
model.frame matches "age" by searching more widely. I'd prefer the error.
I suspect this is hard -- I'd like it to not see the attached lung data
set, but still be able to find the log function.
Is there a not-horribly-complex solution?
I also tried to change the primary function to lm instead of coxph. It
has the same problem, but does print a warning that the newdata and
results have different lengths (which I will incorporate).
Terry T.
More information about the R-devel
mailing list