[R] Problem with function lda of the MASS package

Prof Brian D Ripley ripley at stats.ox.ac.uk
Wed Nov 3 18:22:52 CET 1999


On Wed, 3 Nov 1999, Winfried Theis wrote:

> Dear Prof. Ripley,
> dear R-Users,
> 
> I just tested the function "lda" from the MASS package and got the following
> error-message:
> 
> > test<-lda(rnkonj,nkonj$V14,CV=T)
> Error in NextMethod("lda") : negative length vectors are not allowed

Note that the error message is from NextMethod, not lda.

> I add the used dataset as attachment. There are 14 Variables in this dataset
> and variable 14 is the classification into 4 groups. The dataframe "rnkonj"
> consists only of the first 13 variables without the classification.
> 
> Is it only a problem of NOT giving a value for "subset" -- though I thought
> after reading the help-page, this variable can be omitted...
> 
> I'm running R 0.65.0 from the SuSE-rpm package on a SuSE-Linux 6.2 system with
> a Pentium 200  and 64MB RAM.
> 
> Any ideas or suggestions are welcome!

This is a problem in NextMethod in that version of R, I believe. Any of

test <- read.table("konj554.datR")
lda(V14 ~ ., test)
lda.default(test[, -14], test[, 14])
lda(as.matrix(test[, -14]), test[, 14])

should work there, but

> lda(test[, -14], test[, 14])
Error in NextMethod("lda") : negative length vectors are not allowed

in R 0.65.1 but works correctly in the development version.

As far as I can see using

lda.data.frame <- function (x, ...) 
{
    res <- lda(structure(data.matrix(x), class = "matrix"), ...)
    res$call <- match.call()
    res
}

also works around the problem in NextMethod.

It would be helpful to give a full reproducible script of what you did.
I found this rather hard to debug, as I don't have 0.65.0 on my home
machine (it has been superseded), and I could not generate the error
on the version I normally use.

(I think you will find the formula form more convenient, especially
if you added some variable labels to the data frame.)

-- 
Brian D. Ripley,                  ripley at 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-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list