Skip to content
Prev 1763 / 63424 Next

possible bug in loglm (PR#122)

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.