From noreply at r-forge.r-project.org Sun Feb 2 22:00:04 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 2 Feb 2014 22:00:04 +0100 (CET) Subject: [Vegan-commits] r2848 - in pkg/vegan: data inst Message-ID: <20140202210004.CBB97186D35@r-forge.r-project.org> Author: jarioksa Date: 2014-02-02 22:00:04 +0100 (Sun, 02 Feb 2014) New Revision: 2848 Modified: pkg/vegan/data/BCI.rda pkg/vegan/inst/ChangeLog Log: Use Taxonstand 1.3 (prerelease version) to check the BCI names Modified: pkg/vegan/data/BCI.rda =================================================================== (Binary files differ) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-01-28 04:02:29 UTC (rev 2847) +++ pkg/vegan/inst/ChangeLog 2014-02-02 21:00:04 UTC (rev 2848) @@ -35,15 +35,18 @@ * BCI: names checked after http://www.theplantlist.org, but kept the old (alphabetic) order of species. The changes are: Abarema macradenium -> A. macradenia, Apeiba aspera -> A. glabra, - Aspidosperma cruenta -> A. desmanthum, Chlorophora tinctoria -> - Maclura t., Coccoloba manzanillensis -> C. manzinellensis, Cupania - sylvatica -> C. seemannii, Dipteryx panamensis -> D. oleifera, - Eugenia coloradensis -> E. florida, Eugenia oerstedeana -> - E. oerstediana, Lonchocarpus latifolius -> L. heptaphyllus (this - is ambiguous, since Hebestichma cubense is another alternative), - Phoebe cinnamomifolia -> Cinnamomum triplinerve, Tabebuia guayacan - -> Handroanthus g. Guarea is ambiguous: data have three taxa - (fuzzy, grandifolia and guidonia), but theplanlist.org says + Aspidosperma cruenta -> A. desmanthum, Cassipourea ellipitica -> + C. guianensis, Chlorophora tinctoria -> Maclura t., Coccoloba + manzanillensis -> C. manzinellensis, Cupania sylvatica -> + C. seemannii, Dipteryx panamensis -> D. oleifera, Eugenia + coloradensis -> E. florida, Eugenia oerstedeana -> E. oerstediana, + Inga marginata -> I. semialata, Lonchocarpus latifolius -> + L. heptaphyllus (this is ambiguous, since Hebestichma cubense is + another alternative), Maquira costaricana -> Maquira guianensis + var. costaricana, Phoebe cinnamomifolia -> Cinnamomum triplinerve, + Swartzia simplex var. ochnaceae -> var. continentalis, Tabebuia + guayacan -> Handroanthus g. Guarea is ambiguous: data have three + taxa (fuzzy, grandifolia and guidonia), but theplantlist.org says grandifolia is an ill. synonym of guidonia. This change allows matching 206 of 225 BCI species with http://datadryad.org/resource/doi:10.5061/dryad.63q27. In From noreply at r-forge.r-project.org Wed Feb 5 14:37:23 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Wed, 5 Feb 2014 14:37:23 +0100 (CET) Subject: [Vegan-commits] r2849 - in pkg/vegan: . R inst man Message-ID: <20140205133723.AA4A7186D5F@r-forge.r-project.org> Author: jarioksa Date: 2014-02-05 14:37:22 +0100 (Wed, 05 Feb 2014) New Revision: 2849 Added: pkg/vegan/R/as.hclust.spantree.R Modified: pkg/vegan/NAMESPACE pkg/vegan/inst/ChangeLog pkg/vegan/man/spantree.Rd Log: add as.hclust.spantree Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-02-02 21:00:04 UTC (rev 2848) +++ pkg/vegan/NAMESPACE 2014-02-05 13:37:22 UTC (rev 2849) @@ -94,6 +94,8 @@ S3method(anova, betadisper) S3method(anova, cca) S3method(anova, prc) +# as.hclust: stats +S3method(as.hclust, spantree) ## Do not export as.mcmc now: would need import(coda) # as.mcmc: coda <======= rare #S3method(as.mcmc, oecosimu) Added: pkg/vegan/R/as.hclust.spantree.R =================================================================== --- pkg/vegan/R/as.hclust.spantree.R (rev 0) +++ pkg/vegan/R/as.hclust.spantree.R 2014-02-05 13:37:22 UTC (rev 2849) @@ -0,0 +1,69 @@ +### Casts a vegan spantree object into single linkage dendrogram of +### class hclust. The non-trivial items in "hclust" object are a +### 'merge' matrix for fusions of points and/or clusters, a 'height' +### vector which gives the heights of each fusion, and an 'order' +### vector that gives the order of leaves in the plotted +### dendrogram. The 'height's are only sorted spantree segment +### distances, but for 'merge' we need to establish cluster +### memberships, and for 'order' we must traverse the tree. The +### plot.hclust() function seems to require that the left kid is +### always more compact (a single point or fused earlier than the +### right kid). + +`as.hclust.spantree` <- + function(x, ...) +{ + ## Order by the lengths of spanning tree links + o <- order(x$dist) + npoints <- length(o) + 1 + ## Ordered indices of dads and kids + dad <- (2:npoints)[o] + kid <- x$kid[o] + ## merge matrix of hclust has negative index when a single point + ## is added to a tree and a positive index when a group is joined + ## to a tree, and the group is numbered by the level it was + ## formed. + labs <- -seq_len(npoints) + merge <- matrix(0, nrow=npoints-1, ncol=2) + for(i in 1:nrow(merge)) { + ## add items of labs, keep tighter cluster on the left + items <- c(labs[dad[i]], labs[kid[i]]) + if (items[1] > 0 || items[2] > 0) + items <- sort(items) + else + items <- rev(sort(items)) + merge[i, ] <- items + ## update labs for the current group and its kids + labs[labs %in% labs[c(dad[i], kid[i])]] <- i + } + ## Get order of leaves with recursive search from the root + visited <- matrix(FALSE, nrow = nrow(merge), ncol=ncol(merge)) + order <- numeric(npoints) + ind <- 0 + ## "<<-" updates data only within this function, but outside the + ## visit() function. + visit <- function(i, j) { + if(visited[i,j]) + return(NULL) + else { + visited[i,j] <<- TRUE + } + if (merge[i,j] < 0) { + ind <<- ind+1 + order[ind] <<- -merge[i,j] + if (j == 1) + visit(i, 2) + } else { + visit(merge[i,j], 1) + visit(merge[i,j], 2) + } + } + visit(nrow(merge), 1) + visit(nrow(merge), 2) + + out <- list(merge = merge, height = x$dist[o], order = order, + labels = x$labels, method = "spantree", call = + match.call()) + class(out) <- "hclust" + out +} Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-02-02 21:00:04 UTC (rev 2848) +++ pkg/vegan/inst/ChangeLog 2014-02-05 13:37:22 UTC (rev 2849) @@ -11,6 +11,9 @@ be used in an incorrect context". The dots were added in r2765, and now removed. + * as.hclust.spantree: a new function to cast a "spantree" result + object to an "hclust" tree. + * biplot.rda: failed in axis scaling with negative 'scaling' values when some species had zero variance (and hence species scores was 0/0 = NaN). Modified: pkg/vegan/man/spantree.Rd =================================================================== --- pkg/vegan/man/spantree.Rd 2014-02-02 21:00:04 UTC (rev 2848) +++ pkg/vegan/man/spantree.Rd 2014-02-05 13:37:22 UTC (rev 2849) @@ -1,6 +1,7 @@ \name{spantree} \alias{spantree} \alias{cophenetic.spantree} +\alias{as.hclust.spantree} \alias{plot.spantree} \alias{lines.spantree} \alias{spandepth} @@ -13,6 +14,7 @@ } \usage{ spantree(d, toolong = 0) +\method{as.hclust}{spantree}(x, ...) \method{cophenetic}{spantree}(x) spandepth(x) \method{plot}{spantree}(x, ord, cex = 0.7, type = "p", labels, dlim, @@ -58,6 +60,15 @@ corresponding link is \code{NA}. Connected subtrees can be identified using \code{\link{distconnected}}. + Minimum spanning tree is closesly related to single linkage + clustering, a.k.a. nearest neighbour clustering, and in genetics as + neighbour joining tree available in \code{\link{hclust}} and + \code{\link[cluster]{agnes}} functions. The most important practical + difference is that minimum spanning tree has no concept of cluster + membership, but always joins individual points to each other. Function + \code{as.hclust} can change the \code{spantree} result into a + corresponding \code{\link{hclust}} object. + Function \code{cophenetic} finds distances between all points along the tree segments. Function \code{spandepth} returns the depth of each node. The nodes of a tree are either leaves (with one link) or @@ -132,6 +143,8 @@ ## Depths of nodes depths <- spandepth(tr) plot(tr, type = "t", label = depths) +## Plot as a dendrogram +plot(as.hclust(tr)) } \keyword{ multivariate} From noreply at r-forge.r-project.org Thu Feb 6 10:51:23 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 6 Feb 2014 10:51:23 +0100 (CET) Subject: [Vegan-commits] r2850 - in pkg/vegan: . R inst man Message-ID: <20140206095123.95F3818680B@r-forge.r-project.org> Author: jarioksa Date: 2014-02-06 10:51:23 +0100 (Thu, 06 Feb 2014) New Revision: 2850 Added: pkg/vegan/man/reorder.hclust.Rd Modified: pkg/vegan/NAMESPACE pkg/vegan/R/as.hclust.spantree.R pkg/vegan/inst/ChangeLog Log: provide reorder() and rev() methods for 'hclust' trees Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-02-05 13:37:22 UTC (rev 2849) +++ pkg/vegan/NAMESPACE 2014-02-06 09:51:23 UTC (rev 2850) @@ -192,6 +192,9 @@ # hiersimu: vegan S3method(hiersimu, default) S3method(hiersimu, formula) +# methods for hclust object in base R: these would be better in R +S3method(reorder, hclust) +S3method(rev, hclust) # identify: graphics S3method(identify, ordiplot) # labels: base Modified: pkg/vegan/R/as.hclust.spantree.R =================================================================== --- pkg/vegan/R/as.hclust.spantree.R 2014-02-05 13:37:22 UTC (rev 2849) +++ pkg/vegan/R/as.hclust.spantree.R 2014-02-06 09:51:23 UTC (rev 2850) @@ -5,10 +5,7 @@ ### vector that gives the order of leaves in the plotted ### dendrogram. The 'height's are only sorted spantree segment ### distances, but for 'merge' we need to establish cluster -### memberships, and for 'order' we must traverse the tree. The -### plot.hclust() function seems to require that the left kid is -### always more compact (a single point or fused earlier than the -### right kid). +### memberships, and for 'order' we must traverse the tree. `as.hclust.spantree` <- function(x, ...) @@ -27,16 +24,11 @@ merge <- matrix(0, nrow=npoints-1, ncol=2) for(i in 1:nrow(merge)) { ## add items of labs, keep tighter cluster on the left - items <- c(labs[dad[i]], labs[kid[i]]) - if (items[1] > 0 || items[2] > 0) - items <- sort(items) - else - items <- rev(sort(items)) - merge[i, ] <- items + merge[i, ] <- c(labs[dad[i]], labs[kid[i]]) ## update labs for the current group and its kids labs[labs %in% labs[c(dad[i], kid[i])]] <- i } - ## Get order of leaves with recursive search from the root + ## Get order of leaves with recursive search from the root. visited <- matrix(FALSE, nrow = nrow(merge), ncol=ncol(merge)) order <- numeric(npoints) ind <- 0 @@ -67,3 +59,98 @@ class(out) <- "hclust" out } + +### Internal vegan function to get the 'order' from a merge matrix of +### an hclust tree + +`hclustMergeOrder` <- + function(merge) +{ + ## Get order of leaves with recursive search from the root + visited <- matrix(FALSE, nrow = nrow(merge), ncol=ncol(merge)) + order <- numeric(nrow(merge)+1) + ind <- 0 + ## "<<-" updates data only within this function, but outside the + ## visit() function. + visit <- function(i, j) { + if(visited[i,j]) + return(NULL) + else { + visited[i,j] <<- TRUE + } + if (merge[i,j] < 0) { + ind <<- ind+1 + order[ind] <<- -merge[i,j] + if (j == 1) + visit(i, 2) + } else { + visit(merge[i,j], 1) + visit(merge[i,j], 2) + } + } + visit(nrow(merge), 1) + visit(nrow(merge), 2) + return(order) +} + +### Reorder an hclust tree. Basic R provides reorder.dendrogram, but +### this functoin works with 'hclust' objects, and also differs in +### implementation. We use either weighted mean, min or max or +### sum. The dendrogram is always ordered in ascending order, so that +### with max the left kid always has lower value. So with 'max' the +### largest value is smaller in leftmost group. The choice 'sum' +### hardly makes sense, but it is the default in +### reorder.dendrogram. The ordering with 'mean' differs from +### reorder.dendrogram which uses unweighted means, but here we weight +### means by group sizes so that the mean of an internal node is the +### mean of its leaves. + +`reorder.hclust` <- + function(x, wts, agglo.FUN = c("mean", "min", "max", "sum"), ...) +{ + agglo.FUN <- match.arg(agglo.FUN) + merge <- x$merge + nlev <- nrow(merge) + stats <- numeric(nlev) + counts <- numeric(nlev) + pair <- numeric(2) + pairw <- numeric(2) + ## Go through merge, order each level and update the statistic. + for(i in 1:nlev) { + for(j in 1:2) { + if (merge[i,j] < 0) { + pair[j] <- wts[-merge[i,j]] + pairw[j] <- 1 + } else { + pair[j] <- stats[merge[i,j]] + pairw[j] <- counts[merge[i,j]] + } + } + ## reorder + merge[i,] <- merge[i, order(pair)] + ## statistic for this merge level + stats[i] <- + switch(agglo.FUN, + "mean" = weighted.mean(pair, pairw), + "min" = min(pair), + "max" = max(pair), + "sum" = sum(pair)) + counts[i] <- sum(pairw) + } + ## Get the 'order' of the reordered dendrogram + order <- hclustMergeOrder(merge) + x$merge <- merge + x$order <- order + x$value <- stats + x +} + +### Trivial function to reverse the order of an hclust tree (why this +### is not in base R?) + +`rev.hclust` <- + function(x) +{ + x$order <- rev(x$order) + x +} Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-02-05 13:37:22 UTC (rev 2849) +++ pkg/vegan/inst/ChangeLog 2014-02-06 09:51:23 UTC (rev 2850) @@ -14,6 +14,15 @@ * as.hclust.spantree: a new function to cast a "spantree" result object to an "hclust" tree. + * hclust: add reorder() and rev() methods for standard "hclust" + trees of R. I have no clue why base R does not have these + methods, but I provide them now in vegan. An additional reason for + providing these methods is that reorder(, wts, + agglo.FUN = mean) will use unweighted mean of merged groups even + when these are of very unequal sizes. The reorder method provided + here will use group sizes as weights and the value of the group + will be the mean of its leaves (terminal nodes). + * biplot.rda: failed in axis scaling with negative 'scaling' values when some species had zero variance (and hence species scores was 0/0 = NaN). Added: pkg/vegan/man/reorder.hclust.Rd =================================================================== --- pkg/vegan/man/reorder.hclust.Rd (rev 0) +++ pkg/vegan/man/reorder.hclust.Rd 2014-02-06 09:51:23 UTC (rev 2850) @@ -0,0 +1,94 @@ +\name{reorder.hclust} +\alias{reorder.hclust} +\alias{rev.hclust} + +\title{ +Reorder a Hierarchical Clustering Tree +} + +\description{ + + Function takes a hierarchical clustering tree from + \code{\link{hclust}} and a vector of values and reorders the + clustering tree in the order of the supplied vector, maintaining the + constraints on the tree. This is a method of generic function + \code{\link{reorder}} and an alternative to reordering a + \code{"dendrogram"} object with \code{\link{reorder.dendrogram}} + +} + +\usage{ +\method{reorder}{hclust}(x, wts, agglo.FUN = c("mean", "min", "max", "sum"), ...) +\method{rev}{hclust}(x) +} + +\arguments{ + \item{x}{ + hierarchical clustering from \code{\link{hclust}}. +} + \item{wts}{ + numeric vector for reordering. +} + \item{agglo.FUN}{ + a function for weights agglomeration, see below. +} + \item{\dots}{ + additional arguments (ignored). +} +} + +\details{ + + Dendrograms can be ordered in many ways. The \code{reorder} function + reorders an \code{\link{hclust}} tree and provides an alternative to + \code{\link{reorder.dendrogram}} which can reorder a + \code{\link{dendrogram}}. The current function will also work + differently when the \code{agglo.FUN} is \code{"mean"}: the + \code{\link{reorder.dendrogram}} will always take the direct mean of + member groups ignoring their sizes, but this function will used + \code{\link{weighted.mean}} weighted by group sizes, so that the group + mean is always the mean of member leaves (terminal nodes). + + The function accepts only a limited list of \code{agglo.FUN} + functions for assessing the value of \code{wts} for groups. The + ordering is always ascending, but the order of leaves can be reversed + with \code{rev}. + +} + +\value{ + Reordered \code{\link{hclust}} result object with added item + \code{value} that gives the value of the statistic at each merge + level. +} + +\author{ + Jari Oksanen +} +\note{ + These functions should really be in base \R. +} + + +\seealso{ + \code{\link{hclust}} for getting clustering trees, + \code{\link{as.hclust.spantree}} to change a \pkg{vegan} minimum + spanning tree to an \code{\link{hclust}} object, and + \code{\link{dendrogram}} and \code{\link{reorder.dendrogram}} for an + alternative implementation. +} +\examples{ +data(mite, mite.env) +hc <- hclust(vegdist(wisconsin(sqrt(mite)))) +ohc <- with(mite.env, reorder(hc, WatrCont)) +plot(hc) +plot(ohc) +## Slightly different from reordered 'dendrogram' which ignores group +## sizes in assessing means. +den <- as.dendrogram(hc) +den <- with(mite.env, reorder(den, WatrCont, agglo.FUN = mean)) +plot(den) +} + +\keyword{multivariate} + From noreply at r-forge.r-project.org Fri Feb 7 10:18:50 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 7 Feb 2014 10:18:50 +0100 (CET) Subject: [Vegan-commits] r2851 - pkg/vegan/R Message-ID: <20140207091850.9C2B4186C52@r-forge.r-project.org> Author: jarioksa Date: 2014-02-07 10:18:50 +0100 (Fri, 07 Feb 2014) New Revision: 2851 Modified: pkg/vegan/R/as.hclust.spantree.R Log: rethink hclust tree traversal: it is simple Modified: pkg/vegan/R/as.hclust.spantree.R =================================================================== --- pkg/vegan/R/as.hclust.spantree.R 2014-02-06 09:51:23 UTC (rev 2850) +++ pkg/vegan/R/as.hclust.spantree.R 2014-02-07 09:18:50 UTC (rev 2851) @@ -67,22 +67,14 @@ function(merge) { ## Get order of leaves with recursive search from the root - visited <- matrix(FALSE, nrow = nrow(merge), ncol=ncol(merge)) order <- numeric(nrow(merge)+1) ind <- 0 - ## "<<-" updates data only within this function, but outside the - ## visit() function. + ## "<<-" updates data only within hclustMergeOrder, but outside + ## the visit() function. visit <- function(i, j) { - if(visited[i,j]) - return(NULL) - else { - visited[i,j] <<- TRUE - } if (merge[i,j] < 0) { ind <<- ind+1 order[ind] <<- -merge[i,j] - if (j == 1) - visit(i, 2) } else { visit(merge[i,j], 1) visit(merge[i,j], 2) From noreply at r-forge.r-project.org Fri Feb 7 10:33:46 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 7 Feb 2014 10:33:46 +0100 (CET) Subject: [Vegan-commits] r2852 - pkg/vegan/R Message-ID: <20140207093346.906CA186DF0@r-forge.r-project.org> Author: jarioksa Date: 2014-02-07 10:33:46 +0100 (Fri, 07 Feb 2014) New Revision: 2852 Modified: pkg/vegan/R/as.hclust.spantree.R Log: use hclustMergeOrder in as.hclust.spantree Modified: pkg/vegan/R/as.hclust.spantree.R =================================================================== --- pkg/vegan/R/as.hclust.spantree.R 2014-02-07 09:18:50 UTC (rev 2851) +++ pkg/vegan/R/as.hclust.spantree.R 2014-02-07 09:33:46 UTC (rev 2852) @@ -23,36 +23,13 @@ labs <- -seq_len(npoints) merge <- matrix(0, nrow=npoints-1, ncol=2) for(i in 1:nrow(merge)) { - ## add items of labs, keep tighter cluster on the left merge[i, ] <- c(labs[dad[i]], labs[kid[i]]) ## update labs for the current group and its kids labs[labs %in% labs[c(dad[i], kid[i])]] <- i } - ## Get order of leaves with recursive search from the root. - visited <- matrix(FALSE, nrow = nrow(merge), ncol=ncol(merge)) - order <- numeric(npoints) - ind <- 0 - ## "<<-" updates data only within this function, but outside the - ## visit() function. - visit <- function(i, j) { - if(visited[i,j]) - return(NULL) - else { - visited[i,j] <<- TRUE - } - if (merge[i,j] < 0) { - ind <<- ind+1 - order[ind] <<- -merge[i,j] - if (j == 1) - visit(i, 2) - } else { - visit(merge[i,j], 1) - visit(merge[i,j], 2) - } - } - visit(nrow(merge), 1) - visit(nrow(merge), 2) - + + order <- hclustMergeOrder(merge) + out <- list(merge = merge, height = x$dist[o], order = order, labels = x$labels, method = "spantree", call = match.call()) From noreply at r-forge.r-project.org Sat Feb 8 08:31:55 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sat, 8 Feb 2014 08:31:55 +0100 (CET) Subject: [Vegan-commits] r2853 - in pkg/vegan: R man Message-ID: <20140208073156.16B48186CB4@r-forge.r-project.org> Author: jarioksa Date: 2014-02-08 08:31:55 +0100 (Sat, 08 Feb 2014) New Revision: 2853 Modified: pkg/vegan/R/as.hclust.spantree.R pkg/vegan/man/reorder.hclust.Rd Log: add option for unweighted means in reorder.hclust Modified: pkg/vegan/R/as.hclust.spantree.R =================================================================== --- pkg/vegan/R/as.hclust.spantree.R 2014-02-07 09:33:46 UTC (rev 2852) +++ pkg/vegan/R/as.hclust.spantree.R 2014-02-08 07:31:55 UTC (rev 2853) @@ -75,7 +75,9 @@ ### mean of its leaves. `reorder.hclust` <- - function(x, wts, agglo.FUN = c("mean", "min", "max", "sum"), ...) + function(x, wts, + agglo.FUN = c("mean", "min", "max", "sum", "uwmean"), + ...) { agglo.FUN <- match.arg(agglo.FUN) merge <- x$merge @@ -103,7 +105,8 @@ "mean" = weighted.mean(pair, pairw), "min" = min(pair), "max" = max(pair), - "sum" = sum(pair)) + "sum" = sum(pair), + "uwmean" = mean(pair)) counts[i] <- sum(pairw) } ## Get the 'order' of the reordered dendrogram Modified: pkg/vegan/man/reorder.hclust.Rd =================================================================== --- pkg/vegan/man/reorder.hclust.Rd 2014-02-07 09:33:46 UTC (rev 2852) +++ pkg/vegan/man/reorder.hclust.Rd 2014-02-08 07:31:55 UTC (rev 2853) @@ -18,7 +18,8 @@ } \usage{ -\method{reorder}{hclust}(x, wts, agglo.FUN = c("mean", "min", "max", "sum"), ...) +\method{reorder}{hclust}(x, wts, + agglo.FUN = c("mean", "min", "max", "sum", "uwmean"), ...) \method{rev}{hclust}(x) } @@ -46,13 +47,15 @@ differently when the \code{agglo.FUN} is \code{"mean"}: the \code{\link{reorder.dendrogram}} will always take the direct mean of member groups ignoring their sizes, but this function will used - \code{\link{weighted.mean}} weighted by group sizes, so that the group - mean is always the mean of member leaves (terminal nodes). + \code{\link{weighted.mean}} weighted by group sizes, so that the + group mean is always the mean of member leaves (terminal nodes). If + you want to ignore group sizes, you can use unweighted mean with + \code{"uwmean"}. The function accepts only a limited list of \code{agglo.FUN} functions for assessing the value of \code{wts} for groups. The - ordering is always ascending, but the order of leaves can be reversed - with \code{rev}. + ordering is always ascending, but the order of leaves can be + reversed with \code{rev}. } From noreply at r-forge.r-project.org Sun Feb 9 08:41:48 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 9 Feb 2014 08:41:48 +0100 (CET) Subject: [Vegan-commits] r2854 - in pkg/vegan: . R inst Message-ID: <20140209074148.D8A491845BC@r-forge.r-project.org> Author: jarioksa Date: 2014-02-09 08:41:46 +0100 (Sun, 09 Feb 2014) New Revision: 2854 Added: pkg/vegan/R/scores.hclust.Rd Modified: pkg/vegan/NAMESPACE pkg/vegan/R/as.hclust.spantree.R pkg/vegan/inst/ChangeLog Log: add scores.hclust (to be removed later) Modified: pkg/vegan/NAMESPACE =================================================================== --- pkg/vegan/NAMESPACE 2014-02-08 07:31:55 UTC (rev 2853) +++ pkg/vegan/NAMESPACE 2014-02-09 07:41:46 UTC (rev 2854) @@ -389,6 +389,7 @@ S3method(scores, decorana) S3method(scores, default) S3method(scores, envfit) +S3method(scores, hclust) S3method(scores, lda) S3method(scores, metaMDS) S3method(scores, monoMDS) Modified: pkg/vegan/R/as.hclust.spantree.R =================================================================== --- pkg/vegan/R/as.hclust.spantree.R 2014-02-08 07:31:55 UTC (rev 2853) +++ pkg/vegan/R/as.hclust.spantree.R 2014-02-09 07:41:46 UTC (rev 2854) @@ -126,3 +126,33 @@ x$order <- rev(x$order) x } + +### Get coordinates for internal or terminal nodes (leaves) that would +### be used in plot.hclust + +`scores.hclust` <- + function(x, display = "internal", ...) +{ + extnam <- c("leaves", "terminal") + intnam <- c("internal") + display <- match.arg(display, c(extnam, intnam)) + ## Terminal nodes (leaves): plot.hclust scales x-axis for n points + ## as 1..n. The y-value is the 'height' where the terminal node + ## was fused to the tree. + if(display %in% extnam) { + merge <- x$merge + y <- numeric(nrow(merge) + 1) + for(i in 1:nrow(merge)) + for(j in 1:2) + if(merge[i,j] < 0) + y[-merge[i,j]] <- x$height[i] + xx <- order(x$order) + xy <- cbind(`x` = xx, `height` = y) + } else { + ## Internal nodes are given in the order they were fused which + ## also is the order of 'height' + xx <- reorder(x, order(x$order), agglo.FUN = "uwmean")$value + xy <- cbind(`x`= xx, `height` = x$height) + } + xy +} Added: pkg/vegan/R/scores.hclust.Rd =================================================================== --- pkg/vegan/R/scores.hclust.Rd (rev 0) +++ pkg/vegan/R/scores.hclust.Rd 2014-02-09 07:41:46 UTC (rev 2854) @@ -0,0 +1,70 @@ +\name{scores.hclust} +\alias{scores.hclust} + +\title{ + Coordinates of Leaves and Internal Nodes in a hclust Tree +} + +\description{ The function finds the coordinates that will be used for + internal nodes and leaves when an \code{\link{hclust}} object is + plotted. These help in annotating the plotted dendrogram. } + +\usage{ +scores.hclust(x, display = "internal", ...) +} + +\arguments{ + \item{x}{ + An \code{\link{hclust}} result object. +} + \item{display}{ + Return \code{"internal"} nodes or \code{"terminal"} nodes (also + called \code{"leaves"}. +} + \item{\dots}{ + Other arguments passed to the function (ignored). +} +} + +\details{ + + The function returns the coordinates of nodes in an + \code{\link{hclust}} plot as two-column matrix. First column called + \code{x} gives the horizontal coordinates which for \eqn{n} terminal + nodes (leaves) is an integer sequence \eqn{1..n}. The second column + called \code{height} gives the merge value. For terminal nodes + (leaves) this the value at which the item is merged to the tree, and + in plots the labels can still hang below this level, as defined by + the argument \code{hang} in \code{\link{plot.hclust}}. + + The function only works with \code{\link{hclust}} objects; it does + not work with \code{\link{dendrogram}}. + +} + +\value{ + A two-column matrix of coordinates. +} + +\author{ + Jari Oksanen. +} + +\note{ + This function may be removed as useless. +} + + +\seealso{ + \code{\link{hclust}}, \code{\link{plot.hclust}}. +} +\examples{ +## Show values that were used in reordering a tree +data(mite, mite.env) +hc <- hclust(vegdist(mite)) +hc <- with(mite.env, reorder(hc, WatrCont)) +with(mite.env, plot(hc, labels=round(WatrCont), cex=0.7)) +ordilabel(scores(hc), label=round(hc$value), cex=0.7) +} +\keyword{ multivariate } + Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-02-08 07:31:55 UTC (rev 2853) +++ pkg/vegan/inst/ChangeLog 2014-02-09 07:41:46 UTC (rev 2854) @@ -12,7 +12,7 @@ and now removed. * as.hclust.spantree: a new function to cast a "spantree" result - object to an "hclust" tree. + object to an "hclust" tree. * hclust: add reorder() and rev() methods for standard "hclust" trees of R. I have no clue why base R does not have these @@ -23,6 +23,11 @@ here will use group sizes as weights and the value of the group will be the mean of its leaves (terminal nodes). + Add scores() method to extract coordinates of internal nodes or + leaves from a plotted hclust() tree. The function is whimsical and + may be removed before release (it is documented separately to make + this easier). + * biplot.rda: failed in axis scaling with negative 'scaling' values when some species had zero variance (and hence species scores was 0/0 = NaN). From noreply at r-forge.r-project.org Mon Feb 10 09:40:49 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Mon, 10 Feb 2014 09:40:49 +0100 (CET) Subject: [Vegan-commits] r2855 - in pkg/vegan: R inst man Message-ID: <20140210084049.D89CD18459A@r-forge.r-project.org> Author: jarioksa Date: 2014-02-10 09:40:49 +0100 (Mon, 10 Feb 2014) New Revision: 2855 Modified: pkg/vegan/R/tabasco.R pkg/vegan/inst/ChangeLog pkg/vegan/man/vegemite.Rd Log: tabasco can use reorder.hclust Modified: pkg/vegan/R/tabasco.R =================================================================== --- pkg/vegan/R/tabasco.R 2014-02-09 07:41:46 UTC (rev 2854) +++ pkg/vegan/R/tabasco.R 2014-02-10 08:40:49 UTC (rev 2855) @@ -19,32 +19,44 @@ sp.ind <- order(wascores(use, x)) } else if (inherits(use, c("dendrogram", "hclust", "twins"))) { + ## "twins" and "dendrogram" are treated as "dendrogram", + ## but "hclust" is kept as "hclust": they differ in + ## reorder() if (inherits(use, "twins")) { require(cluster) || stop("package cluster needed to handle 'use'") + use <- as.dendrogram(use) } - if (!inherits(use, "dendrogram")) - use <- as.dendrogram(use) if (!is.null(site.ind)) stop("'site.ind' cannot be used with dendrogram") ## Reorder tree if Rowv specified if (isTRUE(Rowv)) { ## order by first CA axis -- decorana() is fastest tmp <- decorana(x, ira = 1) + ## reorder() command is equal to all, but "dendrogram" + ## will use unweighted mean and "hclust" weighted + ## mean. use <- reorder(use, scores(tmp, dis="sites", choices = 1), - agglo.FUN = mean) + agglo.FUN = "mean") } else if (length(Rowv) > 1) { ## Rowv is a vector if (length(Rowv) != nrow(x)) stop(gettextf("Rowv has length %d, but 'x' has %d rows", length(Rowv), nrow(x))) - use <- reorder(use, Rowv, agglo.FUN = mean) + use <- reorder(use, Rowv, agglo.FUN = "mean") } - site.ind <- seq_len(nrow(x)) - names(site.ind) <- rownames(x) - site.ind <- site.ind[labels(use)] + if (inherits(use, "dendrogram")) { + site.ind <- seq_len(nrow(x)) + names(site.ind) <- rownames(x) + site.ind <- site.ind[labels(use)] + } else { + site.ind <- use$order + } if (is.null(sp.ind)) sp.ind <- order(wascores(order(site.ind), x)) pltree <- use + ## heatmap needs a "dendrogram" + if(!inherits(pltree, "dendrogram")) + pltree <- as.dendrogram(pltree) } else if (is.list(use)) { tmp <- scores(use, choices = 1, display = "sites") @@ -66,24 +78,30 @@ } ## see if sp.ind is a dendrogram or hclust tree if (inherits(sp.ind, c("hclust", "dendrogram", "twins"))) { - if (inherits(sp.ind, "twins")) + if (inherits(sp.ind, "twins")) { require("cluster") || stop("package cluster needed to handle 'sp.ind'") - if (!inherits(sp.ind, "dendrogram")) sp.ind <- as.dendrogram(sp.ind) + } sptree <- sp.ind ## Consider reordering species tree if (isTRUE(Colv) && !is.null(site.ind)) { sptree <- reorder(sptree, wascores(order(site.ind), x), - agglo.FUN = mean) + agglo.FUN = "mean") } else if (length(Colv) > 1) { if (length(Colv) != ncol(x)) stop(gettextf("Colv has length %d, but 'x' has %d columns", length(Colv), ncol(x))) - sptree <- reorder(sptree, Colv, agglo.FUN = mean) + sptree <- reorder(sptree, Colv, agglo.FUN = "mean") } - sp.ind <- seq_len(ncol(x)) - names(sp.ind) <- colnames(x) - sp.ind <- sp.ind[labels(sptree)] + if (inherits(sptree, "dendrogram")) { + sp.ind <- seq_len(ncol(x)) + names(sp.ind) <- colnames(x) + sp.ind <- sp.ind[labels(sptree)] + } else { + sp.ind <- sptree$order + } + if (!inherits(sptree, "dendrogram")) + sptree <- as.dendrogram(sptree) ## reverse: origin in the upper left corner sptree <- rev(sptree) } Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-02-09 07:41:46 UTC (rev 2854) +++ pkg/vegan/inst/ChangeLog 2014-02-10 08:40:49 UTC (rev 2855) @@ -45,6 +45,13 @@ with three points was reported by Paul Bacquet (Louvain, Belgium). + * tabasco: "hclust" objects (use, sp.ind) are reordered using + weighted means. This is a better method than the unweighted means + used for reordering of dendrograms. Earlier "hclust" objects were + changed to dendrograms, but now we provide reorder.hclust() and + rev.hclust() in vegan, and can use improved method of ordering the + table. + * treedive, treedist: default is now match.force = TRUE, and treedive() gained new argument 'verbose' to turn of most messages -- which is practical in oecosimu(). Modified: pkg/vegan/man/vegemite.Rd =================================================================== --- pkg/vegan/man/vegemite.Rd 2014-02-09 07:41:46 UTC (rev 2854) +++ pkg/vegan/man/vegemite.Rd 2014-02-10 08:40:49 UTC (rev 2855) @@ -81,10 +81,14 @@ also for species). When \code{use} is an object from \code{\link{hclust}}, \code{\link[cluster]{agnes}} or a \code{\link{dendrogram}}, the sites are ordered similarly as in the - cluster dendrogram. Function \code{tabasco} re-orders the - dendrogram if \code{Rowv = TRUE} or \code{Rowv} is a vector. Such - re-ordering is not available for \code{vegemite}, but it can be done - by hand using \code{\link{reorder.dendrogram}}. In all cases where + cluster dendrogram. Function \code{tabasco} re-orders the dendrogram + if \code{Rowv = TRUE} or \code{Rowv} is a vector. Such re-ordering is + not available for \code{vegemite}, but it can be done by hand using + \code{\link{reorder.dendrogram}} or \code{\link{reorder.hclust}}. + Please note that \code{\link{dendrogram}} and \code{\link{hclust}} + reordering can differ: unweighted means of merged branches are used in + \code{\link{dendrogram}}, but weighted means (= means of leaves of the + cluster) are used in \code{\link{reorder.hclust}}. In all cases where species scores are missing, species are ordered by their weighted averages (\code{\link{wascores}}) on site order. From noreply at r-forge.r-project.org Tue Feb 11 16:13:12 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Tue, 11 Feb 2014 16:13:12 +0100 (CET) Subject: [Vegan-commits] r2856 - in pkg/vegan: R inst Message-ID: <20140211151312.B3262185E83@r-forge.r-project.org> Author: jarioksa Date: 2014-02-11 16:13:12 +0100 (Tue, 11 Feb 2014) New Revision: 2856 Modified: pkg/vegan/R/add1.cca.R pkg/vegan/inst/ChangeLog Log: ordistep failed with redundant terms (Df=0) in the add scope Modified: pkg/vegan/R/add1.cca.R =================================================================== --- pkg/vegan/R/add1.cca.R 2014-02-10 08:40:49 UTC (rev 2855) +++ pkg/vegan/R/add1.cca.R 2014-02-11 15:13:12 UTC (rev 2856) @@ -32,6 +32,11 @@ } colnames(adds) <- colnames(tmp)[3:4] out <- cbind(out, adds) + ## check for redundant (0 Df) terms + if (any(nas <- out[,1] < 1)) { + out[[3]][nas] <- NA + out[[4]][nas] <- NA + } class(out) <- cl } out Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-02-10 08:40:49 UTC (rev 2855) +++ pkg/vegan/inst/ChangeLog 2014-02-11 15:13:12 UTC (rev 2856) @@ -11,6 +11,9 @@ be used in an incorrect context". The dots were added in r2765, and now removed. + * ordistep: add1.cca reported P=0 for redundant terms with 0 Df, + and this caused an error in ordistep. + * as.hclust.spantree: a new function to cast a "spantree" result object to an "hclust" tree. From noreply at r-forge.r-project.org Thu Feb 20 18:04:41 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 20 Feb 2014 18:04:41 +0100 (CET) Subject: [Vegan-commits] r2857 - in pkg/vegan: R inst Message-ID: <20140220170441.589D4186996@r-forge.r-project.org> Author: psolymos Date: 2014-02-20 18:04:40 +0100 (Thu, 20 Feb 2014) New Revision: 2857 Modified: pkg/vegan/R/adipart.default.R pkg/vegan/R/hiersimu.default.R pkg/vegan/R/multipart.default.R pkg/vegan/inst/ChangeLog Log: non-nested hierarchy leads to non-sensible results Modified: pkg/vegan/R/adipart.default.R =================================================================== --- pkg/vegan/R/adipart.default.R 2014-02-11 15:13:12 UTC (rev 2856) +++ pkg/vegan/R/adipart.default.R 2014-02-20 17:04:40 UTC (rev 2857) @@ -35,7 +35,7 @@ rval <- as.data.frame(rval[rev(1:length(rval))]) l2 <- sapply(rval, function(z) length(unique(z))) if (any(l1 != l2)) - warning("levels are not perfectly nested") + stop("levels are not perfectly nested") ## aggregate response matrix fullgamma <-if (nlevels(rhs[,nlevs]) == 1) Modified: pkg/vegan/R/hiersimu.default.R =================================================================== --- pkg/vegan/R/hiersimu.default.R 2014-02-11 15:13:12 UTC (rev 2856) +++ pkg/vegan/R/hiersimu.default.R 2014-02-20 17:04:40 UTC (rev 2857) @@ -32,7 +32,7 @@ rval <- as.data.frame(rval[rev(1:length(rval))]) l2 <- sapply(rval, function(z) length(unique(z))) if (any(l1 != l2)) - warning("levels are not perfectly nested") + stop("levels are not perfectly nested") ## aggregate response matrix fullgamma <-if (nlevels(rhs[,nlevs]) == 1) Modified: pkg/vegan/R/multipart.default.R =================================================================== --- pkg/vegan/R/multipart.default.R 2014-02-11 15:13:12 UTC (rev 2856) +++ pkg/vegan/R/multipart.default.R 2014-02-20 17:04:40 UTC (rev 2857) @@ -37,7 +37,7 @@ rval <- as.data.frame(rval[rev(1:length(rval))]) l2 <- sapply(rval, function(z) length(unique(z))) if (any(l1 != l2)) - warning("levels are not perfectly nested") + stop("levels are not perfectly nested") ## aggregate response matrix fullgamma <-if (nlevels(rhs[,nlevs]) == 1) Modified: pkg/vegan/inst/ChangeLog =================================================================== --- pkg/vegan/inst/ChangeLog 2014-02-11 15:13:12 UTC (rev 2856) +++ pkg/vegan/inst/ChangeLog 2014-02-20 17:04:40 UTC (rev 2857) @@ -4,6 +4,9 @@ Version 2.1-41 (opened December 12, 2013) + * adipart, multipart, hiersimu: it is now an error to provide + non-nested sampling hierarchy (used to be a warning). + * new version opened with the CRAN release of vegan_2.0-10 on December 12, 2013. From noreply at r-forge.r-project.org Fri Feb 21 08:22:31 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 21 Feb 2014 08:22:31 +0100 (CET) Subject: [Vegan-commits] r2858 - pkg/lmodel2 Message-ID: <20140221072231.654351862B3@r-forge.r-project.org> Author: jarioksa Date: 2014-02-21 08:22:30 +0100 (Fri, 21 Feb 2014) New Revision: 2858 Modified: pkg/lmodel2/DESCRIPTION Log: vignettes/ directory was introduces in R 2.14.0 Modified: pkg/lmodel2/DESCRIPTION =================================================================== --- pkg/lmodel2/DESCRIPTION 2014-02-20 17:04:40 UTC (rev 2857) +++ pkg/lmodel2/DESCRIPTION 2014-02-21 07:22:30 UTC (rev 2858) @@ -5,6 +5,7 @@ Date: 2013-10-17 Author: Pierre Legendre Maintainer: Jari Oksanen +Depends: R (>= 2.14.0) Description: Computes model II simple linear regression using ordinary least squares (OLS), major axis (MA), standard major axis (SMA), and ranged major axis (RMA). From noreply at r-forge.r-project.org Fri Feb 21 11:31:23 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 21 Feb 2014 11:31:23 +0100 (CET) Subject: [Vegan-commits] r2859 - pkg/vegan/R Message-ID: <20140221103123.33882186CE3@r-forge.r-project.org> Author: jarioksa Date: 2014-02-21 11:31:22 +0100 (Fri, 21 Feb 2014) New Revision: 2859 Modified: pkg/vegan/R/add1.cca.R Log: r2856 failed R CMD check Modified: pkg/vegan/R/add1.cca.R =================================================================== --- pkg/vegan/R/add1.cca.R 2014-02-21 07:22:30 UTC (rev 2858) +++ pkg/vegan/R/add1.cca.R 2014-02-21 10:31:22 UTC (rev 2859) @@ -33,7 +33,7 @@ colnames(adds) <- colnames(tmp)[3:4] out <- cbind(out, adds) ## check for redundant (0 Df) terms - if (any(nas <- out[,1] < 1)) { + if (any(nas <- out[,1] < 1, na.rm = TRUE)) { out[[3]][nas] <- NA out[[4]][nas] <- NA } From noreply at r-forge.r-project.org Fri Feb 21 11:37:54 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 21 Feb 2014 11:37:54 +0100 (CET) Subject: [Vegan-commits] r2860 - in pkg/vegan: R man Message-ID: <20140221103754.E1DBF186D31@r-forge.r-project.org> Author: jarioksa Date: 2014-02-21 11:37:54 +0100 (Fri, 21 Feb 2014) New Revision: 2860 Added: pkg/vegan/man/scores.hclust.Rd Removed: pkg/vegan/R/scores.hclust.Rd Log: scores.hclust.Rd was in the wrong directory Deleted: pkg/vegan/R/scores.hclust.Rd =================================================================== --- pkg/vegan/R/scores.hclust.Rd 2014-02-21 10:31:22 UTC (rev 2859) +++ pkg/vegan/R/scores.hclust.Rd 2014-02-21 10:37:54 UTC (rev 2860) @@ -1,70 +0,0 @@ -\name{scores.hclust} -\alias{scores.hclust} - -\title{ - Coordinates of Leaves and Internal Nodes in a hclust Tree -} - -\description{ The function finds the coordinates that will be used for - internal nodes and leaves when an \code{\link{hclust}} object is - plotted. These help in annotating the plotted dendrogram. } - -\usage{ -scores.hclust(x, display = "internal", ...) -} - -\arguments{ - \item{x}{ - An \code{\link{hclust}} result object. -} - \item{display}{ - Return \code{"internal"} nodes or \code{"terminal"} nodes (also - called \code{"leaves"}. -} - \item{\dots}{ - Other arguments passed to the function (ignored). -} -} - -\details{ - - The function returns the coordinates of nodes in an - \code{\link{hclust}} plot as two-column matrix. First column called - \code{x} gives the horizontal coordinates which for \eqn{n} terminal - nodes (leaves) is an integer sequence \eqn{1..n}. The second column - called \code{height} gives the merge value. For terminal nodes - (leaves) this the value at which the item is merged to the tree, and - in plots the labels can still hang below this level, as defined by - the argument \code{hang} in \code{\link{plot.hclust}}. - - The function only works with \code{\link{hclust}} objects; it does - not work with \code{\link{dendrogram}}. - -} - -\value{ - A two-column matrix of coordinates. -} - -\author{ - Jari Oksanen. -} - -\note{ - This function may be removed as useless. -} - - -\seealso{ - \code{\link{hclust}}, \code{\link{plot.hclust}}. -} -\examples{ -## Show values that were used in reordering a tree -data(mite, mite.env) -hc <- hclust(vegdist(mite)) -hc <- with(mite.env, reorder(hc, WatrCont)) -with(mite.env, plot(hc, labels=round(WatrCont), cex=0.7)) -ordilabel(scores(hc), label=round(hc$value), cex=0.7) -} -\keyword{ multivariate } - Copied: pkg/vegan/man/scores.hclust.Rd (from rev 2859, pkg/vegan/R/scores.hclust.Rd) =================================================================== --- pkg/vegan/man/scores.hclust.Rd (rev 0) +++ pkg/vegan/man/scores.hclust.Rd 2014-02-21 10:37:54 UTC (rev 2860) @@ -0,0 +1,70 @@ +\name{scores.hclust} +\alias{scores.hclust} + +\title{ + Coordinates of Leaves and Internal Nodes in a hclust Tree +} + +\description{ The function finds the coordinates that will be used for + internal nodes and leaves when an \code{\link{hclust}} object is + plotted. These help in annotating the plotted dendrogram. } + +\usage{ +scores.hclust(x, display = "internal", ...) +} + +\arguments{ + \item{x}{ + An \code{\link{hclust}} result object. +} + \item{display}{ + Return \code{"internal"} nodes or \code{"terminal"} nodes (also + called \code{"leaves"}. +} + \item{\dots}{ + Other arguments passed to the function (ignored). +} +} + +\details{ + + The function returns the coordinates of nodes in an + \code{\link{hclust}} plot as two-column matrix. First column called + \code{x} gives the horizontal coordinates which for \eqn{n} terminal + nodes (leaves) is an integer sequence \eqn{1..n}. The second column + called \code{height} gives the merge value. For terminal nodes + (leaves) this the value at which the item is merged to the tree, and + in plots the labels can still hang below this level, as defined by + the argument \code{hang} in \code{\link{plot.hclust}}. + + The function only works with \code{\link{hclust}} objects; it does + not work with \code{\link{dendrogram}}. + +} + +\value{ + A two-column matrix of coordinates. +} + +\author{ + Jari Oksanen. +} + +\note{ + This function may be removed as useless. +} + + +\seealso{ + \code{\link{hclust}}, \code{\link{plot.hclust}}. +} +\examples{ +## Show values that were used in reordering a tree +data(mite, mite.env) +hc <- hclust(vegdist(mite)) +hc <- with(mite.env, reorder(hc, WatrCont)) +with(mite.env, plot(hc, labels=round(WatrCont), cex=0.7)) +ordilabel(scores(hc), label=round(hc$value), cex=0.7) +} +\keyword{ multivariate } + From noreply at r-forge.r-project.org Fri Feb 21 11:41:49 2014 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 21 Feb 2014 11:41:49 +0100 (CET) Subject: [Vegan-commits] r2861 - pkg/vegan/man Message-ID: <20140221104149.B2F60184C14@r-forge.r-project.org> Author: jarioksa Date: 2014-02-21 11:41:49 +0100 (Fri, 21 Feb 2014) New Revision: 2861 Modified: pkg/vegan/man/scores.hclust.Rd Log: Usage as for an S3 method Modified: pkg/vegan/man/scores.hclust.Rd =================================================================== --- pkg/vegan/man/scores.hclust.Rd 2014-02-21 10:37:54 UTC (rev 2860) +++ pkg/vegan/man/scores.hclust.Rd 2014-02-21 10:41:49 UTC (rev 2861) @@ -10,7 +10,7 @@ plotted. These help in annotating the plotted dendrogram. } \usage{ -scores.hclust(x, display = "internal", ...) +\method{scores}{hclust}(x, display = "internal", ...) } \arguments{