[Vegan-commits] r2938 - in pkg/vegan: . R man vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Mar 12 08:28:07 CET 2015
Author: jarioksa
Date: 2015-03-12 08:28:07 +0100 (Thu, 12 Mar 2015)
New Revision: 2938
Modified:
pkg/vegan/NAMESPACE
pkg/vegan/R/goodness.cca.R
pkg/vegan/R/ordiArrowTextXY.R
pkg/vegan/man/goodness.cca.Rd
pkg/vegan/man/ordiarrows.Rd
pkg/vegan/man/vegan-internal.Rd
pkg/vegan/vignettes/FAQ-vegan.texi
Log:
Merge branch 'cran-2.2' into r-forge-svn-local
export ordiArrow*, goodness.cca gains addprevious
Modified: pkg/vegan/NAMESPACE
===================================================================
--- pkg/vegan/NAMESPACE 2015-03-11 07:18:55 UTC (rev 2937)
+++ pkg/vegan/NAMESPACE 2015-03-12 07:28:07 UTC (rev 2938)
@@ -16,10 +16,10 @@
mrpp, msoplot, mso, multipart, make.commsim, nestedbetajac, nestedbetasor, nestedchecker,
nesteddisc, nestedn0, nestednodf, nestedtemp, nullmodel, oecosimu,
ordiareatest,
-ordiR2step, ordiarrows, ordicloud, ordicluster, ordiellipse, ordigrid,
+ordiR2step, ordiarrows, ordiArrowMul, ordiArrowTextXY, ordicloud, ordicluster, ordiellipse, ordigrid,
ordihull, ordilabel, ordiplot, ordipointlabel, ordiresids,
ordisegments, ordispider, ordisplom, ordistep, ordisurf,
-orditkplot, orditorp, ordixyplot,
+orditkplot, orditorp, ordixyplot,
pcnm, permatfull, permatswap, permustats, permutest,
poolaccum, postMDS, prc, prestondistr, prestonfit, procrustes,
protest, radfit, radlattice, rankindex, rarefy, rarecurve, raupcrick,
Modified: pkg/vegan/R/goodness.cca.R
===================================================================
--- pkg/vegan/R/goodness.cca.R 2015-03-11 07:18:55 UTC (rev 2937)
+++ pkg/vegan/R/goodness.cca.R 2015-03-12 07:28:07 UTC (rev 2938)
@@ -1,7 +1,7 @@
`goodness.cca` <-
function (object, display = c("species", "sites"), choices,
model = c("CCA", "CA"), statistic = c("explained", "distance"),
- summarize = FALSE, addpartial = TRUE, ...)
+ summarize = FALSE, addprevious = TRUE, ...)
{
model <- match.arg(model)
display <- match.arg(display)
@@ -56,8 +56,12 @@
vexp <- vexp[, choices, drop = FALSE]
if (statistic == "explained") {
tot <- ptot + ctot + rtot
- if (addpartial && model == "CCA" && !is.null(object$pCCA))
- vexp <- sweep(vexp, 1, ptot, "+")
+ if (addprevious) {
+ if (!is.null(object$pCCA))
+ vexp <- sweep(vexp, 1, ptot, "+")
+ if (model == "CA" && !is.null(object$CCA))
+ vexp <- sweep(vexp, 1, ctot, "+")
+ }
vexp <- sweep(vexp, 1, tot, "/")
}
else {
Modified: pkg/vegan/R/ordiArrowTextXY.R
===================================================================
--- pkg/vegan/R/ordiArrowTextXY.R 2015-03-11 07:18:55 UTC (rev 2937)
+++ pkg/vegan/R/ordiArrowTextXY.R 2015-03-12 07:28:07 UTC (rev 2938)
@@ -1,18 +1,18 @@
-### Location of the text at the point of the arrow. 'vect' are the
+### Location of the text at the point of the arrow. 'x' are the
### coordinates of the arrow heads, and 'labels' are the text used to
### label these heads, '...' passes arguments (such as 'cex') to
### strwidth() and strheight().
`ordiArrowTextXY` <-
- function (vect, labels, ...)
+ function (x, labels, ...)
{
w <- strwidth(labels, ...)
h <- strheight(labels, ...)
## slope of arrows
- b <- vect[,2]/vect[,1]
+ b <- x[,2]/x[,1]
## offset based on string dimensions
- off <- cbind(sign(vect[,1]) * (w/2 + h/4), 0.75 * h * sign(vect[,2]))
+ off <- cbind(sign(x[,1]) * (w/2 + h/4), 0.75 * h * sign(x[,2]))
## move the centre of the string to the continuation of the arrow
- for(i in 1:nrow(vect)) {
+ for(i in seq_len(nrow(x))) {
move <- off[i,2] / b[i]
## arrow points to the top/bottom of the text box
if (is.finite(move) && abs(move) <= abs(off[i, 1]))
@@ -21,7 +21,7 @@
## arrow points to a side of the text box
move <- b[i] * off[i,1]
off[i, 2] <- move
- }
+ }
}
- off + vect
+ off + x
}
Modified: pkg/vegan/man/goodness.cca.Rd
===================================================================
--- pkg/vegan/man/goodness.cca.Rd 2015-03-11 07:18:55 UTC (rev 2937)
+++ pkg/vegan/man/goodness.cca.Rd 2015-03-12 07:28:07 UTC (rev 2938)
@@ -20,7 +20,7 @@
\usage{
\method{goodness}{cca}(object, display = c("species", "sites"), choices,
model = c("CCA", "CA"), statistic = c("explained", "distance"),
- summarize = FALSE, addpartial = TRUE, ...)
+ summarize = FALSE, addprevious = TRUE, ...)
inertcomp(object, display = c("species", "sites"),
statistic = c("explained", "distance"), proportional = FALSE)
spenvcor(object)
@@ -48,9 +48,14 @@
\item{summarize}{Show only the accumulated total.}
- \item{addpartial}{Add the variation explained by conditions
- (partialled out variation) to the constraints when
- \code{statistic="explained"}.}
+ \item{addprevious}{Add the variation explained by previous components
+ when \code{statistic="explained"}. For \code{model="CCA"} add
+ conditionened (partialled out) variation, and for \code{model="CA"}
+ add both conditioned and constrained variation. This will give
+ cumulative explanation. The argument has no effect when
+ \code{statistic="distance"}, but this will always show the residual
+ distance after current axis and all previous components.
+ }
\item{proportional}{Give the inertia components as proportional for
the corresponding total.}
Modified: pkg/vegan/man/ordiarrows.Rd
===================================================================
--- pkg/vegan/man/ordiarrows.Rd 2015-03-11 07:18:55 UTC (rev 2937)
+++ pkg/vegan/man/ordiarrows.Rd 2015-03-12 07:28:07 UTC (rev 2938)
@@ -2,6 +2,8 @@
\alias{ordiarrows}
\alias{ordisegments}
\alias{ordigrid}
+\alias{ordiArrowMul}
+\alias{ordiArrowTextXY}
\title{Add Arrows and Line Segments to Ordination Diagrams}
@@ -17,6 +19,10 @@
show.groups, label = FALSE, ...)
ordigrid(ord, levels, replicates, display = "sites", lty = c(1,1),
col = c(1,1), lwd = c(1,1), ...)
+
+ordiArrowMul(x, at = c(0,0), fill = 0.75)
+
+ordiArrowTextXY(x, labels, ...)
}
\arguments{
@@ -56,18 +62,39 @@
\item{\dots}{Parameters passed to graphical functions such as
\code{\link{lines}}, \code{\link{segments}}, \code{\link{arrows}},
- or to \code{\link{scores}} to select axes and scaling etc. }
+ or to \code{\link{scores}} to select axes and scaling etc. }
+
+ \item{x}{two-column matrix (or matrix-like object) containing the
+ coordinates of arrow heads on the two plot axes.}
+
+ \item{at}{numeric vector of coordinates for the origin of the arrows.}
+
+ \item{fill}{numeric; the proportion of the plot to fill by the span of
+ the arrows.}
+
+ \item{labels}{vector of character strings of length \code{nrow(x)}
+ that are to be used to label arrows.}
}
\details{ Function \code{ordiarrows} draws \code{\link{arrows}} and
\code{ordisegments} draws line \code{\link{segments}} between
successive items in the groups. Function \code{ordigrid} draws line
\code{\link{segments}} both within the groups and for the
- corresponding items among the groups. }
+ corresponding items among the groups.
+ \code{ordiArrowMul} finds a multiplier to scale a bunch of arrows to
+ fill an ordination plot, and \code{ordiArrowTextXY} finds the
+ coordinates for labels of these arrows. See \code{\link{envfit}} for
+ an application.
+}
+
\note{These functions add graphical items to ordination graph: You must
draw a graph first.
- }
+
+ \code{ordiArrowTextXY} does not draw labels; it simply returns
+ coordinates at which the labels should be drawn for use with another
+ function, such as \code{\link{text}}.
+}
\author{ Jari Oksanen }
\seealso{The functions pass parameters to basic graphical functions, and
@@ -89,5 +116,21 @@
ordiarrows(mod, ditch, label = TRUE, show = c("6", "9"),
col = 2)
legend("topright", c("Control", "Pyrifos 44"), lty = 1, col = c(1,2))
+
+## Biplot arrows by hand
+data(varespec, varechem)
+ord <- cca(varespec ~ Al + P + K, varechem)
+plot(ord, display = c("species","sites"))
+## biplot scores
+bip <- scores(ord, choices = 1:2, display = "bp")
+## scaling factor for arrows to fill 80% of plot
+(mul <- ordiArrowMul(bip, fill = 0.8))
+bip.scl <- bip * mul # Scale the biplot scores
+labs <- c("Al","P","K") # Arrow labels
+## calculate coordinate of labels for arrows
+(bip.lab <- ordiArrowTextXY(bip.scl, labels = labs))
+## draw arrows and text labels
+arrows(0, 0, bip.scl[,1], bip.scl[,2], length = 0.1)
+text(bip.lab, labels = labs)
}
\keyword{aplot }
Modified: pkg/vegan/man/vegan-internal.Rd
===================================================================
--- pkg/vegan/man/vegan-internal.Rd 2015-03-11 07:18:55 UTC (rev 2937)
+++ pkg/vegan/man/vegan-internal.Rd 2015-03-12 07:28:07 UTC (rev 2938)
@@ -8,8 +8,6 @@
\alias{centroids.cca}
\alias{ordiTerminfo}
\alias{pasteCall}
-\alias{ordiArrowMul}
-\alias{oridArrowTextXY}
\alias{ordiArgAbsorber}
\alias{veganCovEllipse}
\alias{hierParseFormula}
@@ -28,8 +26,6 @@
ordiTerminfo(d, data)
ordiNAexclude(x, excluded)
ordiNApredict(omit, x)
-ordiArrowMul(x, at = c(0,0), fill = 0.75)
-ordiArrowTextXY(vect, labels, ...)
ordiArgAbsorber(..., shrink, origin, scaling, triangular,
display, choices, const, FUN)
centroids.cca(x, mf, wt)
@@ -63,11 +59,6 @@
\code{ordiNApredict} pads the result object with these or with
WA scores similarly as \code{\link{napredict}}.
- \code{ordiArrowMul} finds a multiplier to scale a bunch of arrows to
- fill an ordination plot, and \code{ordiArrowTextXY} finds the
- coordinates for labels of these arrows. See \code{\link{envfit}}
- for an application.
-
\code{ordiArgAbsorber} absorbs arguments of \code{\link{scores}}
function of \pkg{vegan} so that these do not cause superfluous
warnings in graphical function \code{FUN}. If you implement
Modified: pkg/vegan/vignettes/FAQ-vegan.texi
===================================================================
--- pkg/vegan/vignettes/FAQ-vegan.texi 2015-03-11 07:18:55 UTC (rev 2937)
+++ pkg/vegan/vignettes/FAQ-vegan.texi 2015-03-12 07:28:07 UTC (rev 2938)
@@ -8,7 +8,7 @@
@setfilename FAQ- at pkg{vegan}.info
@settitle @pkg{vegan} FAQ
@setchapternewpage on
- at set FAQ_YEAR 2014
+ at set FAQ_YEAR 2015
@afourpaper
@c %**end of header
@@ -25,7 +25,7 @@
Creative Commons, 543 Howard Street, 5th Floor, San Francisco,
California, 94105, USA.
-Copyright @copyright{} 2008-2013 Jari Oksanen
+Copyright @copyright{} 2008-2015 vegan development team
@end quotation
@end copying
@@ -638,14 +638,14 @@
used @code{arrow.mul} which is saved as an attribute of @code{biplot}
scores.
-An unexported function @code{ordiArrowMul} is used to find the scaling
-for the current plot. You can use this function to see how arrows would
-be scaled:
+Function @code{ordiArrowMul} is used to find the scaling for the
+current plot. You can use this function to see how arrows would be
+scaled:
@example
sol <- cca(varespec)
ef <- envfit(sol ~ ., varechem)
plot(sol)
-vegan:::ordiArrowMul(scores(ef, display="vectors"))
+ordiArrowMul(scores(ef, display="vectors"))
@end example
@node I want to use Helmert or sum contrasts, What are aliased variables and how to see them?, How are environmental arrows scaled?, Ordination
More information about the Vegan-commits
mailing list