Re: [R] 3d plots of mca() results?

About this list Date view Thread view Subject view Author view

From: Uwe Ligges (ligges@statistik.uni-dortmund.de)
Date: Tue 13 Mar 2001 - 20:31:39 EST


Message-ID: <3AADF70B.66D25E19@statistik.uni-dortmund.de>

Andrew Perrin wrote:
>
> Greetings.
>
> I'm about to embark on my first big (to me at least!) R project, which
> will be to write a function to plot three-dimensional multiple
> correspondence analysis (mca) plots in a manner similar to
> scatterplot3d(). (plot.mca() plots only two dimensions, even though
> mca() will calculate more.) Before I do so, however, I would love to know
> that I'm not reinventing the wheel or any other similarly common
> implements. Has anyone done this before?

In plot.mca() the function eqscplot() is used ("with scales chosen to be
equal on both axes").
It is not easy to get such a behaviour with scatterplot3d().

On the other hand, plotting a mca object should be easy using
scatterplot3d(), e.g. along the lines of plot.mca():

plot3d.mca <- function (x, rows = T, col, cex = par("cex"), ...)
{
    library(scatterplot3d)
    if (length(cex) == 1)
        cex <- rep(cex, 2)
    s3d <- scatterplot3d(x$cs, type = "n", xlab = "", ...)
    if (missing(col)) {
        col <- par("col")
        if (!is.numeric(col))
            col <- match(col, palette())
        col <- c(col, col + 1)
    }
    else if (length(col) != 2)
        col <- rep(col, length = 2)
    if (rows) {
        s3d.temp <- s3d$xyz.convert(x$rs)
        text(s3d.temp, labels = seq(along = x$rs), cex = cex[1], col = col[1],
...)
    }
    s3d.temp <- s3d$xyz.convert(x$cs)
    text(s3d.temp, labels = dimnames(x$cs)[[1]], cex = cex[2], col =
col[2], ...)
    invisible(x)
}

Example:
  data(farms)
  plot3d.mca(mca(farms, abbrev=TRUE, nf=3))


Don't hurt me for any errors, this was a quick hack ....

Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view

This archive was generated by hypermail 2b30 : Fri 22 Jun 2001 - 18:58:36 EST