[R] how to use plot.lda included in MASS package?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Jun 16 08:31:51 CEST 2005
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 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 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list