[Vegan-commits] r1767 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sun Aug 28 17:47:50 CEST 2011
Author: jarioksa
Date: 2011-08-28 17:47:50 +0200 (Sun, 28 Aug 2011)
New Revision: 1767
Modified:
pkg/vegan/R/metaMDSrotate.R
pkg/vegan/R/monoMDS.R
pkg/vegan/R/print.monoMDS.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/monoMDS.Rd
Log:
harmonize info on pc rotation between mono/metaMDS and make metaMDSrotate work with monoMDS
Modified: pkg/vegan/R/metaMDSrotate.R
===================================================================
--- pkg/vegan/R/metaMDSrotate.R 2011-08-28 08:59:14 UTC (rev 1766)
+++ pkg/vegan/R/metaMDSrotate.R 2011-08-28 15:47:50 UTC (rev 1767)
@@ -2,10 +2,15 @@
`metaMDSrotate` <-
function(object, vec, na.rm = FALSE, ...)
{
- if (!inherits(object, "metaMDS"))
- stop(gettextf("function works only with 'metaMDS' results"))
+ workswith <- c("metaMDS", "monoMDS")
+ if (!inherits(object, workswith))
+ stop(gettextf("function works only with the results of: %s",
+ paste(workswith, collapse = ", ")))
x <- object$points
- sp <- object$species
+ if (is.null(object$species))
+ sp <- NA
+ else
+ sp <- object$species
N <- NCOL(x)
if (N < 2)
stop(gettextf("needs at least 2 dimensions"))
Modified: pkg/vegan/R/monoMDS.R
===================================================================
--- pkg/vegan/R/monoMDS.R 2011-08-28 08:59:14 UTC (rev 1766)
+++ pkg/vegan/R/monoMDS.R 2011-08-28 15:47:50 UTC (rev 1767)
@@ -109,7 +109,7 @@
sol$points <- matrix(sol$points, nobj, k)
if (pc)
sol$points <- prcomp(sol$points)$x
- sol$pc <- pc
+ attr(sol$points, "pc") <- pc
rownames(sol$points) <- nm
colnames(sol$points) <- paste("MDS", 1:k, sep="")
class(sol) <- "monoMDS"
Modified: pkg/vegan/R/print.monoMDS.R
===================================================================
--- pkg/vegan/R/print.monoMDS.R 2011-08-28 08:59:14 UTC (rev 1766)
+++ pkg/vegan/R/print.monoMDS.R 2011-08-28 15:47:50 UTC (rev 1767)
@@ -22,7 +22,7 @@
cat("scaled to unit root mean square")
else
cat("unscaled")
- if (x$pc)
+ if (attr(x$points, "pc"))
cat(", rotated to principal components")
cat("\n")
stoplab <- switch(x$icause,
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2011-08-28 08:59:14 UTC (rev 1766)
+++ pkg/vegan/inst/ChangeLog 2011-08-28 15:47:50 UTC (rev 1767)
@@ -17,6 +17,8 @@
probably this is a user error (but can be intentional and
correct).
+ * metaMDSrotate: can rotate monoMDS() results.
+
* monoMDS: gained argument 'pc' (defaults TRUE) to rotate the
final scores to principal components.
Modified: pkg/vegan/man/monoMDS.Rd
===================================================================
--- pkg/vegan/man/monoMDS.Rd 2011-08-28 08:59:14 UTC (rev 1766)
+++ pkg/vegan/man/monoMDS.Rd 2011-08-28 15:47:50 UTC (rev 1767)
@@ -128,6 +128,15 @@
\code{\link{stressplot}} can be used to display the kind of
regression in each \code{model}.
+ Scaling, orientation and direction of the axes is arbitrary.
+ However, the function always centres the axes, and the default
+ \code{scaling} is to scale the configuration ot unit root mean
+ square and to rotate the axes (argument \code{pc}) to principal
+ components so that the first dimension shows the major variation.
+ It is possible to rotate the solution so that the first axis is
+ parallel to a given environmental variable using fuction
+ \code{\link{metaMDSrotate}}.
+
}
\value{ Returns an object of class \code{"monoMDS"}. The final scores
More information about the Vegan-commits
mailing list