[Vegan-commits] r712 - in pkg/vegan: R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 3 17:54:21 CET 2009


Author: jarioksa
Date: 2009-03-03 17:54:21 +0100 (Tue, 03 Mar 2009)
New Revision: 712

Added:
   pkg/vegan/R/metaMDSrotate.R
Modified:
   pkg/vegan/inst/ChangeLog
   pkg/vegan/man/metaMDS.Rd
Log:
metaMDSrotate: new function to rotate a metaMDS result to an environmental factor

Added: pkg/vegan/R/metaMDSrotate.R
===================================================================
--- pkg/vegan/R/metaMDSrotate.R	                        (rev 0)
+++ pkg/vegan/R/metaMDSrotate.R	2009-03-03 16:54:21 UTC (rev 712)
@@ -0,0 +1,27 @@
+### Rotates metaMDS result so that axis one is parallel to vector 'x'
+`metaMDSrotate` <-
+function(object, vec, choices = 1:2, ...) 
+{
+    if (!inherits(object, "metaMDS"))
+        stop("function works only with 'metaMDS' results")
+    if (length(choices) != 2)
+        stop("function can be only used with 2dim plots")
+    vec <- drop(vec)
+    if (length(dim(vec)) > 1)
+        stop("function can be only with one dimensional 'x'")
+    ## envfit finds the direction cosine
+    rot <- envfit(object, vec, choices = choices, ...)$vectors$arrows
+    rot <- drop(rot)
+    ## rotation matrix [[sin theta, cos theta] [-cos theta, sin theta]]
+    rot <- rbind(rot, rev(rot))
+    rot[2,1] <- -rot[2,1]
+    ## transpose (inverse) of the rotation matrix
+    rot <- t(rot)
+    ## Rotation of points and species scores
+    object$points[] <- object$points %*% rot
+    attr(object$points, "pc") <- FALSE
+    if (!is.null(object$species))
+        object$species[] <- object$species %*% rot
+    object
+}
+

Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog	2009-03-03 06:59:45 UTC (rev 711)
+++ pkg/vegan/inst/ChangeLog	2009-03-03 16:54:21 UTC (rev 712)
@@ -4,15 +4,18 @@
 
 Version 1.16-14 (opened Feb 24, 2009)
 
-    * permat.tsdiag: time series diagnostics for permat objects.
-    Performs a first order ARIMA model and Ljung-Box test for the
-    independence of the residuals. This function is useful to
-    diagnose independence for sequential algorithms.
+	* metaMDSrotate: a new function to rotate metaMDS configuration so
+	that the first axis is parallel with a continuous site variable.
+	
+	* permat.tsdiag: time series diagnostics for permat objects.
+	Performs a first order ARIMA model and Ljung-Box test for the
+	independence of the residuals. This function is useful to diagnose
+	independence for sequential algorithms.
 
-    * lagplot.permat: lagplot for permat simulations to graphically
-    diagnose independence when using sequential algorithms.
-    Reworked examples on the help page shows time series related
-    diagnostics for permat objects.
+	* lagplot.permat: lagplot for permat simulations to graphically
+	diagnose independence when using sequential algorithms.  Reworked
+	examples on the help page shows time series related diagnostics
+	for permat objects.
 
 	* permatswap: two new methods (under "abuswap") added based on the
 	paper of Hardy 2008 (J Ecol 96, 914-926). These preserve row *and*

Modified: pkg/vegan/man/metaMDS.Rd
===================================================================
--- pkg/vegan/man/metaMDS.Rd	2009-03-03 06:59:45 UTC (rev 711)
+++ pkg/vegan/man/metaMDS.Rd	2009-03-03 16:54:21 UTC (rev 712)
@@ -10,6 +10,7 @@
 \alias{points.metaMDS}
 \alias{text.metaMDS}
 \alias{scores.metaMDS}
+\alias{metaMDSrotate}
 
 \title{Nonmetric Multidimensional Scaling with Stable Solution from
   Random Starts, Axis Scaling and Species Scores}
@@ -42,6 +43,7 @@
 postMDS(X, dist, pc=TRUE, center=TRUE, halfchange=TRUE, threshold=0.8,
         nthreshold=10, plot=FALSE, ...)
 metaMDSredist(object, ...)
+metaMDSrotate(object, vec, choices, ...)
 }
 
 \arguments{
@@ -98,6 +100,7 @@
   \item{threshold}{Largest dissimilarity used in half-change scaling. }
   \item{nthreshold}{ Minimum number of points in half-change scaling. }
   \item{object}{A result object from \code{metaMDS}.}
+  \item{vec}{A continuous site variable (vector).}
   \item{...}{Other parameters passed to functions.}
 }
 \details{
@@ -170,7 +173,10 @@
     Centring moves the origin to the
     average of the axes.  Principal components rotate the configuration
     so that the variance of points is maximized on first
-    dimension. Half-change scaling scales the configuration so that one 
+    dimension (with function \code{metaMDSrotate} you can alternatively 
+    rotate the configuration so that the first axis is parallel to an 
+    environmental variable). 
+    Half-change scaling scales the configuration so that one 
     unit means halving of community similarity from replicate similarity.
     Half-change scaling is
     based on closer dissimilarities where the relation between ordination



More information about the Vegan-commits mailing list