From ripley@stats.ox.ac.uk  Fri Nov  5 19:03:17 1999
From: ripley@stats.ox.ac.uk (Prof Brian D Ripley)
Date: Fri, 5 Nov 1999 19:03:17 +0000 (GMT)
Subject: rpart problem (PR#313)
In-Reply-To: <199911051810.TAA14930@pubhealth.ku.dk>
Message-ID: <Pine.GSO.4.05.9911051900140.14373-100000@auk.stats>

On Fri, 5 Nov 1999 david_m_potter@groton.pfizer.com wrote:

> * * * Just the Facts * * *
> call to rpart() with a factor response gives
> the error message:
> 
> "Error: first argument is array, but not matrix."

This is an error in diag() for 0.65.1, only. It will be fixed in the next
release. (It was discussed on r-devel a few days ago.)

> In rpart(), I believe this line causes the error message:
> 
>         temp <- rp$dnode[, -(1:3)] %*% diag(init$parms[1:numclass] *
> nobs/init$counts)

Yes. put an as.vector inside the argument to diag, for now, or fix diag to
be

function (x = 1, nrow, ncol = n) 
{
    if (is.matrix(x) && nargs() == 1) {
        if ((m <- min(dim(x))) == 0) 
            return(numeric(0))
        y <- c(x)[1 + 0:(m - 1) * (dim(x)[1] + 1)]
        nms <- dimnames(x)
        if (is.list(nms) && !any(sapply(nms, is.null)) && all((nm <-nms[[1]][1:m]) == 
            nms[[2]][1:m])) 
            names(y) <- nm
        return(y)
    }
    if (is.array(x) && length(dim(x)) != 1) 
#                   ^^^^^^^^^^^^^^^^^^^^^^

        stop("first argument is array, but not matrix.")
    if (missing(x)) 
        n <- nrow
    else if (length(x) == 1 && missing(nrow) && missing(ncol)) {
        n <- as.integer(x)
        x <- 1
    }
    else n <- length(x)
    if (!missing(nrow)) 
        n <- nrow
    p <- ncol
    y <- array(0, c(n, p))
    if ((m <- min(n, p)) > 0) 
        y[1 + 0:(m - 1) * (n + 1)] <- x
    y
}

-- 
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


rpart problem (PR#313)
Prof Brian D Ripley