[Vegan-commits] r1342 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Nov 1 17:11:58 CET 2010
Author: jarioksa
Date: 2010-11-01 17:11:58 +0100 (Mon, 01 Nov 2010)
New Revision: 1342
Modified:
pkg/vegan/R/scores.rda.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/plot.cca.Rd
Log:
const in scores.rda can be a vector of two items: one for species, second for sites
Modified: pkg/vegan/R/scores.rda.R
===================================================================
--- pkg/vegan/R/scores.rda.R 2010-11-01 14:25:51 UTC (rev 1341)
+++ pkg/vegan/R/scores.rda.R 2010-11-01 16:11:58 UTC (rev 1342)
@@ -1,4 +1,4 @@
-"scores.rda" <-
+`scores.rda` <-
function (x, choices = c(1, 2), display = c("sp", "wa", "cn"),
scaling = 2, const, ...)
{
@@ -25,8 +25,18 @@
nrow(x$CA$u)
else
nrow(x$CCA$u)
+ ## const multiplier of scores
if (missing(const))
const <- sqrt(sqrt((nr-1) * sumev))
+ ## canoco 3 compatibility -- canoco 4 is incompatible
+ ##else if (pmatch(const, "canoco")) {
+ ## const <- (sqrt(nr-1), sqrt(nr))
+ ##}
+ ##
+ ## const[1] for species, const[2] for sites and friends
+ if (length(const) == 1) {
+ const <- c(const, const)
+ }
rnk <- x$CCA$rank
sol <- list()
if ("species" %in% take) {
@@ -38,7 +48,7 @@
v <- sweep(v, 1, x$colsum, "/")
v <- v * sqrt(sumev / (nr - 1))
}
- v <- const * v
+ v <- const[1] * v
}
sol$species <- v
}
@@ -47,7 +57,7 @@
if (scaling) {
scal <- list(slam, 1, sqrt(slam))[[abs(scaling)]]
wa <- sweep(wa, 2, scal, "*")
- wa <- const * wa
+ wa <- const[2] * wa
}
sol$sites <- wa
}
@@ -56,7 +66,7 @@
if (scaling) {
scal <- list(slam, 1, sqrt(slam))[[abs(scaling)]]
u <- sweep(u, 2, scal, "*")
- u <- const * u
+ u <- const[2] * u
}
sol$constraints <- u
}
@@ -78,7 +88,7 @@
if (scaling) {
scal <- list(slam, 1, sqrt(slam))[[abs(scaling)]]
cn <- sweep(cn, 2, scal, "*")
- cn <- const * cn
+ cn <- const[2] * cn
}
sol$centroids <- cn
}
@@ -93,6 +103,9 @@
## Only one type of scores: return a matrix instead of a list
if (length(sol) == 1)
sol <- sol[[1]]
+ ## collapse const if both items identical
+ if (identical(const[1], const[2]))
+ const <- const[1]
attr(sol, "const") <- const
return(sol)
}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2010-11-01 14:25:51 UTC (rev 1341)
+++ pkg/vegan/inst/ChangeLog 2010-11-01 16:11:58 UTC (rev 1342)
@@ -4,6 +4,15 @@
Version 1.18-15 (opened November 1, 2010)
+ * rda: the scaling 'const' can now be a vector of two items: the
+ first is used for species and the second for sites. This allows
+ compatibility with Canoco 3.x (but Canoco 4 changed scaling): if
+ 'mod' is an rda() result, and 'nr' is the number of rows in data,
+ then "scaling = -2, const = c(sqrt(nr-1), sqrt(nr))" in scores(),
+ summary() or plot() will use default scaling of Canoco 3.x. Help
+ page now points to decision decision vignette explaining scaling
+ and 'const'.
+
* prc: coefficients folded in a wrong way. Diagnosed, reported and
fixed by Cajo ter Braak.
Modified: pkg/vegan/man/plot.cca.Rd
===================================================================
--- pkg/vegan/man/plot.cca.Rd 2010-11-01 14:25:51 UTC (rev 1341)
+++ pkg/vegan/man/plot.cca.Rd 2010-11-01 16:11:58 UTC (rev 1342)
@@ -69,8 +69,12 @@
vector which is \code{TRUE} for displayed items or a vector of indices
of displayed items.}
\item{const}{General scaling constant to \code{rda} scores. The
- default is to use constant to give biplot scores, or scores that
- approximate original data.}
+ default is to use a constant that tries to scale species and sites
+ similarly but to give biplot scores, or scores that approximate
+ original data (see \code{\link{vignette}}
+ \samp{decision-vegan.pdf} with \code{\link{vegandocs}} for details
+ and discussion). If \code{const} is a vector of two items, the
+ first is used for species, and the second item for site scores.}
\item{axes}{Number of axes in summaries.}
\item{digits}{Number of digits in output.}
\item{n, head, tail}{Number of rows printed from the head and tail of
@@ -160,6 +164,7 @@
text(mod, "species", col="blue", cex=0.8)
## Limited output of 'summary'
head(summary(mod), tail=2)
-}
+## Read description of scaling in RDA in vegan:
+\dontrun{vegandocs("decision")}}
\keyword{hplot}
\keyword{aplot}
More information about the Vegan-commits
mailing list