From: Gavin Simpson <gavin.simpson_at_ucl.ac.uk>

Date: Wed, 30 Jul 2008 20:14:15 +0100

panel.abline(v = 0, lty = "dashed")

rotation[1,1] <- min(rotation[1,1], 1)

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 30 Jul 2008 - 19:42:05 GMT

Date: Wed, 30 Jul 2008 20:14:15 +0100

On Wed, 2008-07-30 at 17:37 +0100, Gavin Simpson wrote:

> On Wed, 2008-07-30 at 04:59 -0700, Andrewjohnclose wrote:

*> > Hi, I have been trying to create a function to generate a Procrustes plot,
**> > generated from package "vegan"
**> > in lattice.
*

<snip />

*> >
*

> > I can generate an empty plot, but not much else - hope someone can help and

*> > point out the obvious!
**> >
**> > Kind regards
**> >
**> > Andrew
**>
**> The obvious thing is that whole thing is wrong! ;-)
**>
**> What's wrong with the standard plot?
*

<snip />

OK, the above question aside, how does the following set of functions suit?

xyplot.procrustes <- function(object, choices = 1:2, xlab, ylab, ...) {

dat <- data.frame(x = object$Yrot[, choices[1]],

y = object$Yrot[, choices[2]]) if(missing(xlab)) xlab <- paste("Dimension", choices[1]) if(missing(ylab)) ylab <- paste("Dimension", choices[2]) xyplot(y ~ x, data = dat, type = "p", rotation = object$rotation, X = object$X, choices = choices, aspect = "iso", xlab = xlab, ylab = ylab, panel = panel.procrustes, prepanel = prepanel.procrustes, ...)}

panel.procrustes <- function(x, y, rotation, X, choices,

ar.col = "blue", length = 0.05, ...) {panel.abline(h = 0, lty = "dashed")

panel.abline(v = 0, lty = "dashed")

rotation[1,1] <- min(rotation[1,1], 1)

panel.abline(0, tan(acos(rotation[1, 1])), lty = "solid") panel.abline(0, 1/tan(acos(-rotation[1, 1])), lty = "solid") panel.points(x, y, ...) panel.arrows(x0 = x, y0 = y, x1 = X[, choices[1]], y1 = X[,choices[2]], length = length, col = ar.col)}

prepanel.procrustes <- function(x, y, X, choices, ...) {

xlim <- range(x, X[, choices[1]])

ylim <- range(y, X[, choices[2]])

list(ylim = ylim, xlim = xlim)

}

## and an example

require(vegan) require(lattice) example(protest)

xyplot(vare.proc)

Note that this only reproduces the which = 1 plot from plot.procrustes. And it is far from bulletproof as I haven't put in any checks, and I probably haven't got the passing of graphics parameters sorted out or even allow the level of customisation that you can get with plot.procrustes, but it does reproduce the output of that function for which = 1. (but all that despite the fact that this has only taken 20 minutes to cook up, plus a tube journey to consult Deepayan's Lattice book for inspiration!)

I'll try to tart this up a bit and see about reproducing the functionality of plot.procrustes which = 2 and then perhaps stick it in vegan when I get a minute and can talk to Jari about making the function fit in with the other ordination lattice functions currently in vegan.

**HTH
**
G

*>
**> G
*

R-help_at_r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 30 Jul 2008 - 19:42:05 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Wed 30 Jul 2008 - 20:34:10 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*