[Vegan-commits] r931 - in pkg/vegan: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Aug 20 16:04:22 CEST 2009
Author: jarioksa
Date: 2009-08-20 16:04:21 +0200 (Thu, 20 Aug 2009)
New Revision: 931
Modified:
pkg/vegan/R/ordiellipse.R
pkg/vegan/R/ordihull.R
pkg/vegan/inst/ChangeLog
pkg/vegan/man/ordihull.Rd
Log:
ordiellipse and ordihull gained arg 'label' to name the hulls or ellipses and invisibly return their plotting objects
Modified: pkg/vegan/R/ordiellipse.R
===================================================================
--- pkg/vegan/R/ordiellipse.R 2009-08-20 08:25:53 UTC (rev 930)
+++ pkg/vegan/R/ordiellipse.R 2009-08-20 14:04:21 UTC (rev 931)
@@ -1,7 +1,7 @@
"ordiellipse" <-
function (ord, groups, display = "sites", kind = c("sd", "se"),
conf, draw = c("lines", "polygon"), w = weights(ord, display),
- show.groups, ...)
+ show.groups, label = FALSE, ...)
{
## Define Circle for an ellipse: taken from the 'car' package
theta <- (0:51) * 2 * pi/51
@@ -23,6 +23,7 @@
}
out <- seq(along = groups)
inds <- names(table(groups))
+ res <- list()
for (is in inds) {
gr <- out[groups == is]
if (length(gr) > 2) {
@@ -39,7 +40,12 @@
ordiArgAbsorber(xy, FUN = lines, ...)
else
ordiArgAbsorber(xy[, 1], xy[, 2], FUN = polygon, ...)
+ if (label)
+ ordiArgAbsorber(mat$center[1], mat$center[2], labels=is,
+ FUN = text, ...)
+ res[[is]] <- mat
}
}
- invisible()
+ class(res) <- "ordiellipse"
+ invisible(res)
}
Modified: pkg/vegan/R/ordihull.R
===================================================================
--- pkg/vegan/R/ordihull.R 2009-08-20 08:25:53 UTC (rev 930)
+++ pkg/vegan/R/ordihull.R 2009-08-20 14:04:21 UTC (rev 931)
@@ -1,6 +1,6 @@
"ordihull" <-
function (ord, groups, display = "sites", draw = c("lines", "polygon"),
- show.groups, ...)
+ show.groups, label = FALSE, ...)
{
draw <- match.arg(draw)
pts <- scores(ord, display = display, ...)
@@ -11,6 +11,7 @@
}
out <- seq(along = groups)
inds <- names(table(groups))
+ res <- list()
for (is in inds) {
gr <- out[groups == is]
if (length(gr) > 1) {
@@ -20,7 +21,14 @@
if (draw == "lines")
ordiArgAbsorber(X[hpts, ], FUN = lines, ...)
else ordiArgAbsorber(X[hpts,], FUN = polygon, ...)
+ if (label) {
+ cntr <- colMeans(X[hpts[-1],])
+ ordiArgAbsorber(cntr[1], cntr[2], labels = is,
+ FUN = text, ...)
+ }
+ res[[is]] <- X[hpts,]
}
}
- invisible()
+ class(res) <- "ordihull"
+ invisible(res)
}
Modified: pkg/vegan/inst/ChangeLog
===================================================================
--- pkg/vegan/inst/ChangeLog 2009-08-20 08:25:53 UTC (rev 930)
+++ pkg/vegan/inst/ChangeLog 2009-08-20 14:04:21 UTC (rev 931)
@@ -4,6 +4,15 @@
Version 1.16-24 (opened August 17, 2009)
+ * ordiellipse & ordihull: gained new argument 'label' to put the
+ name of the group in the centre of the ellipse or the hull. The
+ functions now return invisibly data on their plots for each
+ plotted item: ordiellipse() the covariance matrix (cov.wt()
+ result), and ordihull() the coordinates of the hull
+ vertices. Nothing is done with these yet, but the intention is to
+ write a summary() method to give the coordinates of the centres
+ and surface areas of the plotted hulls or ellipses.
+
* ordiellipse: does not depend on the 'ellipse' package, but finds
the coordinates of ellipse using the equation taken from the 'car'
package. However, this devel version of 'vegan' still must SUGGEST
Modified: pkg/vegan/man/ordihull.Rd
===================================================================
--- pkg/vegan/man/ordihull.Rd 2009-08-20 08:25:53 UTC (rev 930)
+++ pkg/vegan/man/ordihull.Rd 2009-08-20 14:04:21 UTC (rev 931)
@@ -21,17 +21,17 @@
}
\usage{
ordihull(ord, groups, display = "sites", draw = c("lines","polygon"),
+ show.groups, label = FALSE, ...)
+ordiellipse(ord, groups, display="sites", kind = c("sd","se"), conf,
+ draw = c("lines","polygon"), w = weights(ord, display),
+ show.groups, label = FALSE, ...)
+ordispider(ord, groups, display="sites", w = weights(ord, display),
show.groups, ...)
ordiarrows(ord, groups, levels, replicates, display = "sites",
show.groups, startmark, ...)
ordisegments(ord, groups, levels, replicates, display = "sites",
show.groups, ...)
ordigrid(ord, levels, replicates, display = "sites", ...)
-ordispider(ord, groups, display="sites", w = weights(ord, display),
- show.groups, ...)
-ordiellipse(ord, groups, display="sites", kind = c("sd","se"), conf,
- draw = c("lines","polygon"), w = weights(ord, display),
- show.groups, ...)
ordicluster(ord, cluster, prune = 0, display = "sites",
w = weights(ord, display), ...)
}
@@ -55,6 +55,8 @@
\code{TRUE}. This argument makes it possible to use different
colours and line types for groups. The default is to show all
groups. }
+ \item{label}{Label the centroid of the hull or the ellipse with the
+ group name.}
\item{startmark}{plotting characer used to mark the first
item. The default is to use no mark, and for instance,
\code{startmark = 1} will draw a circle. For other plotting characters,
@@ -85,7 +87,15 @@
Function \code{ordihull} draws \code{\link{lines}} or
\code{\link{polygon}}s for the convex
hulls found by function \code{\link{chull}} encircling
- the items in the groups.
+ the items in the groups.
+
+ Function \code{ordiellipse} draws \code{\link{lines}} or
+ \code{\link{polygon}}s for dispersion \code{\link[ellipse]{ellipse}}
+ using either standard deviation of point scores or standard error of
+ the (weighted) average of scores, and the (weighted) correlation
+ defines the direction of the principal axis of the ellipse.
+ An ellipsoid hull can be drawn with function
+ \code{\link[cluster]{ellipsoidhull}} of package \pkg{cluster}.
Function \code{ordiarrows} draws
\code{\link{arrows}} and \code{ordisegments} draws line
@@ -103,14 +113,6 @@
\code{\link{rda}} result without \code{groups} argument, the function
connects each `WA' scores to the correspoding `LC' score.
- Function \code{ordiellipse} draws \code{\link{lines}} or
- \code{\link{polygon}}s for dispersion \code{\link[ellipse]{ellipse}}
- using either standard deviation of point scores or standard error of
- the (weighted) average of scores, and the (weighted) correlation
- defines the direction of the principal axis of the ellipse. An
- ellipsoid hull can be drawn with function
- \code{\link[cluster]{ellipsoidhull}} of package \pkg{cluster}.
-
Function \code{ordicluster} overlays a cluster dendrogram onto
ordination. It needs the result from a hierarchic clustering such as
\code{\link{hclust}} or \code{\link[cluster]{agnes}}, or other
@@ -141,7 +143,7 @@
attach(dune.env)
## pass non-graphical arguments without warnings
plot(mod, type="n", scaling = 3)
-ordihull(mod, Management, scaling = 3)
+ordihull(mod, Management, scaling = 3, label = TRUE)
ordispider(mod, col="red", scaling = 3)
plot(mod, type = "p", display="sites")
ordicluster(mod, hclust(vegdist(dune)), prune=3, col = "blue")
More information about the Vegan-commits
mailing list