[R] possible bug in loglm (PR#122)
Prof Brian Ripley
Prof Brian Ripley <ripley@stats.ox.ac.uk>
Thu, 18 Feb 1999 18:06:52 +0000 (GMT)
> From: D.A.Wooff@durham.ac.uk
> Date: Thu, 18 Feb 1999 18:09:33 +0100
> To: r-devel@stat.math.ethz.ch
> Subject: [R] possible bug in loglm (PR#122)
> CC: R-bugs@biostat.ku.dk
> X-Loop: R-bugs@biostat.ku.dk
>
> Bug report: there is a problem with loglm (or some underlying code)
> when used with updating within a function. For example, this code
> works as expected, when used outside a function:
Well, loglm is not part of R per se, so I was a little surprised to see
this going to R-bugs. The answer is along the lines of `yes, we know,
this is part of the limitations of update and NextMethod', and this occurs
in S-PLUS too, and for lots of other applications of update. You could
alter update.loglm to be
update.loglm <- function (object, formula., ...)
{
setdiff <- function(x, y) if (length(x) == 0 || length(y) == 0) x
else x[match(x, y, 0) == 0]
if (is.null(call <- object$call))
stop("object has no call component. Updating not possible")
if (fix <- !missing(formula.)) {
object$formula <- denumerate(object$formula)
formula. <- denumerate(formula.)
call$formula <- update.formula(formula(object), formula.)
}
extras <- match.call(expand.dots = FALSE)$...
if (length(extras) > 0) {
existing <- !is.na(match(names(extras), names(call)))
## do these individually to allow NULL to remove entries.
for (a in names(extras)[existing]) call[[a]] <- extras[[a]]
if (any(!existing)) {
call <- c(as.list(call), extras[!existing])
call <- as.call(call)
}
}
result <- eval(call, sys.frame(sys.parent()))
if (fix) {
form <- renumerate(result$formula)
result$call$formula <- unclass(result$formula <- form)
}
result
}
that is to remove the NextMethod call. But this sort of thing is quite
common, and the usual workaround is to make sure that the dataframe is visible.
--
Brian D. Ripley, ripley@stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._