* * * Just the Facts * * * call to rpart() with a factor response gives the error message: "Error: first argument is array, but not matrix." * * * Example Code * * * =============================================R : Copyright 1999, The R Development Core Team Version 0.65.1 Release (October 07, 1999) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type "?license" or "?licence" for distribution details. R is a collaborative project with many contributors. Type "?contributors" for a list. Type "demo()" for some demos, "help()" for on-line help, or "help.start()" for a HTML browser interface to help. Type "q()" to quit R.> library(rpart) > x _ 1:50 > y _ as.factor(rbinom(50,1,.5)) > fit _ rpart(y~x,method="class")Error: first argument is array, but not matrix.>* * * Version Information * * * ============================================= --please do not edit the information below-- Version: platform = sparc-sun-solaris2.6 arch = sparc os = solaris2.6 system = sparc, solaris2.6 status = Release major = 0 minor = 65.1 year = 1999 month = October day = 07 language = R Search Path: .GlobalEnv, package:rpart, Autoloads, package:base * * * Unsolicited Hypothesis * * * In rpart(), I believe this line causes the error message: temp <- rp$dnode[, -(1:3)] %*% diag(init$parms[1:numclass] * nobs/init$counts) Thanks for your attention. David David M. Potter Mathematical & Statistical Sciences Pfizer Central Research PO Box 8003/832 Groton, CT 06340-8003 Tel 860-715-1769 ; Fax 860-715-5445 potterdm@groton.pfizer.com -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._