[Vegan-commits] r2158 - pkg/vegan/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 10 09:43:47 CEST 2012


Author: jarioksa
Date: 2012-05-10 09:43:47 +0200 (Thu, 10 May 2012)
New Revision: 2158

Modified:
   pkg/vegan/R/ordiplot3d.R
Log:
rotated arrows must be expressed against projected origin in ordiplot3d

Modified: pkg/vegan/R/ordiplot3d.R
===================================================================
--- pkg/vegan/R/ordiplot3d.R	2012-05-10 06:39:47 UTC (rev 2157)
+++ pkg/vegan/R/ordiplot3d.R	2012-05-10 07:43:47 UTC (rev 2158)
@@ -36,6 +36,8 @@
                    col = arr.col)
         }
     }
+    ## save the location of the origin
+    pl$origin <- matrix(unlist(pl$xyz.convert(0, 0, 0)), nrow=1)
     ## Add function that flattens 3d envfit object so that it can be
     ## projected on the created 3d graph
     xyz2xy <- pl$xyz.convert
@@ -44,6 +46,8 @@
             rn <- rownames(object$vectors$arrows)
             object$vectors$arrows <-
                 sapply(xyz2xy(object$vectors$arrows), cbind)
+            object$vectors$arrows <-
+                sweep(object$vector$arrows, 2, pl$origin)
             rownames(object$vectors$arrows) <- rn
         }
         if (!is.null(object$factors)) {
@@ -55,8 +59,6 @@
         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)



More information about the Vegan-commits mailing list