[Vegan-commits] r2157 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu May 10 08:39:47 CEST 2012
Author: jarioksa
Date: 2012-05-10 08:39:47 +0200 (Thu, 10 May 2012)
New Revision: 2157
Modified:
pkg/vegan/R/ordiplot3d.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/ordiplot3d.Rd
Log:
Squashed commit of the following:
commit ffa3ddf9d62bc8d7afd62abe60fce9960625f474
Merge: ddad83c 4ebe87b
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date: Wed May 9 23:10:15 2012 +0300
Merge branch 'master' of https://github.com/jarioksa/vegan
commit ddad83cce47306420223502d69cacc7f15e9c912
Author: Jari Oksanen <jari.oksanen at oulu.fi>
Date: Wed May 9 23:04:57 2012 +0300
ordiplot3d returns projected origin and function envfit.convert
The envfit.convert function projects a 3-d envfit object to the
the current 3d plot, and together with projected origin can be used
to project the result to the plot:
mod <- cca(varespec)
ef <- envfit(mod ~ ., varechem, choices = 1:3)
pl3 <- ordiplot3d(mod)
plot(pl3$envfit.convert(ef), at = pl3$origin, p.max = 0.05)
Modified: pkg/vegan/R/ordiplot3d.R
===================================================================
--- pkg/vegan/R/ordiplot3d.R 2012-05-08 19:38:52 UTC (rev 2156)
+++ pkg/vegan/R/ordiplot3d.R 2012-05-10 06:39:47 UTC (rev 2157)
@@ -36,6 +36,28 @@
col = arr.col)
}
}
+ ## Add function that flattens 3d envfit object so that it can be
+ ## projected on the created 3d graph
+ xyz2xy <- pl$xyz.convert
+ envfit.convert <- function(object) {
+ if (!is.null(object$vectors)) {
+ rn <- rownames(object$vectors$arrows)
+ object$vectors$arrows <-
+ sapply(xyz2xy(object$vectors$arrows), cbind)
+ rownames(object$vectors$arrows) <- rn
+ }
+ if (!is.null(object$factors)) {
+ rn <- rownames(object$factors$centroids)
+ object$factors$centroids <-
+ sapply(xyz2xy(object$factors$centroids), cbind)
+ rownames(object$factors$centroids) <- rn
+ }
+ object
+ }
+ pl$envfit.convert <- envfit.convert
+ ## save the location of the origin
+ pl$origin <- matrix(unlist(pl$xyz.convert(0, 0, 0)), nrow=1)
+ ## save projected coordinates of points
tmp <- pl$xyz.convert(x)
pl$points <- cbind(tmp$x, tmp$y)
rownames(pl$points) <- rownames(x)
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2012-05-08 19:38:52 UTC (rev 2156)
+++ pkg/vegan/inst/ChangeLog 2012-05-10 06:39:47 UTC (rev 2157)
@@ -15,6 +15,10 @@
metaMDS. With over-defined models there is an infinite number of
different solutions with nearly zero stress, and no convergence is
found.
+
+ * ordiplot3d: function returns the projected coordinates of the
+ origin, and function envfit.convert() that can project a
+ three-dimensional envfit() result to the current plot.
Version 2.1-14 (opened March 9, 2012)
Modified: pkg/vegan/man/ordiplot3d.Rd
===================================================================
--- pkg/vegan/man/ordiplot3d.Rd 2012-05-08 19:38:52 UTC (rev 2156)
+++ pkg/vegan/man/ordiplot3d.Rd 2012-05-10 06:39:47 UTC (rev 2157)
@@ -129,16 +129,19 @@
Function \code{ordiplot3d} returns invisibly an object of class
\code{"ordiplot3d"} inheriting from \code{\link{ordiplot}}. The
return object will contain the coordinates projected onto two
- dimensions for \code{"points"}, and possibly for the heads of
- \code{"arrows"} and \code{"centroids"} of environmental
- variables. Functions like \code{\link{identify.ordiplot}},
+ dimensions for \code{points}, and the projected coordinates of
+ \code{origin}, and possibly the projected coordinates of the heads
+ of \code{arrows} and \code{centroids} of environmental variables.
+ Functions like \code{\link{identify.ordiplot}},
\code{\link{points.ordiplot}}, \code{\link{text.ordiplot}} can use
this result, as well as \code{\link{ordihull}} and other functions
- documented with the latter. In addition, the result will contain the
- object returned by \code{\link[scatterplot3d]{scatterplot3d}},
- including function \code{xyz.convert} which projects
- three-dimensional coordinates onto the plane used in the current
- plot (see Examples).
+ documented with the latter. The result will also contain the object
+ returned by \code{\link[scatterplot3d]{scatterplot3d}}, including
+ function \code{xyz.convert} which projects three-dimensional
+ coordinates onto the plane used in the current plot (see
+ Examples). In addition, there is a function \code{envfit.convert}
+ that projects a three-dimensional \code{\link{envfit}} object to the
+ current plot.
Function \code{ordirgl} returns nothing.
More information about the Vegan-commits
mailing list