Re: [R] how to use plot.lda included in MASS package?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu 16 Jun 2005 - 16:31:51 EST

The main answer is to follow the examples in the book for which this is support software. (That answer is in the R posting guide, too.)

plot.lda is in the MASS namespace, and can be seen via getAnywhere() (so you can find them `anywhere'). panel.lda is defined in plot.lda.

You should almost never call methods like plot.lda() directly. If you ask for help on it, you get

      ## S3 method for class 'lda':
      plot(x, panel = panel.lda, ..., cex = 0.7, dimen,
           abbrev = FALSE, xlab = "LD1", ylab = "LD2")

Note that you are supplying default arguments. Just call

plot(drug.lda, dimen = 1, type ="density")

In particular, you have given a panel function for a 1D plot which does not use one.

I am unable to reproduce anything like the message you got, e.g.

example(z)
plot(z, panel = panel.lda, cex = 0.7, dimen = 1, abbrev = FALSE,

      type ="density")

works. Perhaps your R or MASS package is way out of date? (You haven't told us: see the R posting guide.)

On Thu, 16 Jun 2005, wu sz wrote:

> Hi there,
>
> I am a master student in Denmark, and apply R to analyze the drug data.
>
> I use the function 'lda' to obtain a linear discriminant object, and
> then wish to use 'plot.lda' to do the plot on this object like below.
>
> drug.lda <- lda(Inhibition ~ NET_CHARGE + PKA_1 + MW + MLOGP,
> data = drug.class, method = "moment")
>
> plot.lda(drug.lda, panel = panel.lda, cex = 0.7, dimen = 1, abbrev = FALSE,
> type ="density")
>
> but I got an error message: Error: couldn't find function "plot.lda"
> and then I tried
>
> plot(drug.lda, panel = panel.lda, cex = 0.7, dimen = 1, abbrev = FALSE,
> type ="density")
>
> still an error message was returned: Error in plot.default(drug.lda,
> panel = panel.lda, cex = 0.7, : argument 2 matches multiple formal
> arguments
>
> Also I can't find this panel function, panel.lda anywhere. Do you know
> how to use this plot function?

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Jun 16 16:39:37 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:43 EST