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

Uwe Ligges ligges at statistik.uni-dortmund.de
Tue Mar 13 11:31:39 CET 2001

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"), ...) 
    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], ...)

  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 at stat.math.ethz.ch

More information about the R-help mailing list