[Vegan-commits] r2397 - in branches/2.0: R inst man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jan 31 09:19:02 CET 2013
Author: jarioksa
Date: 2013-01-31 09:19:01 +0100 (Thu, 31 Jan 2013)
New Revision: 2397
Modified:
branches/2.0/R/treedist.R
branches/2.0/R/treedive.R
branches/2.0/inst/ChangeLog
branches/2.0/man/treedive.Rd
Log:
merge 2392,3: matching names in treedist() and treedive()
Modified: branches/2.0/R/treedist.R
===================================================================
--- branches/2.0/R/treedist.R 2013-01-30 16:56:45 UTC (rev 2396)
+++ branches/2.0/R/treedist.R 2013-01-31 08:19:01 UTC (rev 2397)
@@ -1,9 +1,16 @@
`treedist` <-
- function(x, tree, relative = TRUE, ...)
+ function(x, tree, relative = TRUE, match.force = FALSE, ...)
{
n <- nrow(x)
ABJ <- matrix(0, n , n)
dmat <- as.matrix(cophenetic(tree))
+ ## match names
+ if (ncol(x) != ncol(dmat) || match.force) {
+ if(!match.force)
+ warning("Dimensions do not match between 'x' and 'tree' - matching by names")
+ nm <- colnames(x)
+ dmat <- dmat[nm, nm]
+ }
for(j in 1:n) {
for (k in j:n) {
jk <- x[j,] > 0 | x[k,] > 0
Modified: branches/2.0/R/treedive.R
===================================================================
--- branches/2.0/R/treedive.R 2013-01-30 16:56:45 UTC (rev 2396)
+++ branches/2.0/R/treedive.R 2013-01-31 08:19:01 UTC (rev 2397)
@@ -19,6 +19,7 @@
if (!all(fnd))
warning("not all names of 'tree' found in 'comm'")
comm <- comm[, tree$labels[fnd]]
+ m <- m[tree$labels[fnd], tree$labels[fnd]]
if (length(unique(tree$labels)) != length(tree$labels))
stop("names not unique in 'tree': match wrong")
if (length(unique(colnames(comm))) != ncol(comm))
Modified: branches/2.0/inst/ChangeLog
===================================================================
--- branches/2.0/inst/ChangeLog 2013-01-30 16:56:45 UTC (rev 2396)
+++ branches/2.0/inst/ChangeLog 2013-01-31 08:19:01 UTC (rev 2397)
@@ -7,6 +7,7 @@
* merge 2934 (partial, mc): oecosimu handles nestedfun() returning
data.frame. Not merged: checking length of statistic when setting
its name.
+ * merge 2932,3: matching names in treedive() and treedist().
* merge 2384: new FAQ entries.
* merge 2383: remove alias to print.wcmdscale.
* merge 2374,2376,2378,2382: orditorp gains argument select
Modified: branches/2.0/man/treedive.Rd
===================================================================
--- branches/2.0/man/treedive.Rd 2013-01-30 16:56:45 UTC (rev 2396)
+++ branches/2.0/man/treedive.Rd 2013-01-31 08:19:01 UTC (rev 2397)
@@ -13,17 +13,18 @@
\usage{
treedive(comm, tree, match.force = FALSE)
treeheight(tree)
-treedist(x, tree, relative = TRUE, ...)
+treedist(x, tree, relative = TRUE, match.force = FALSE, ...)
}
\arguments{
\item{comm, x}{Community data frame or matrix.}
\item{tree}{A dendrogram which for \code{treedive} must be for species
(columns).}
- \item{match.force}{Force matching of column names in \code{comm} and
- labels in \code{tree}. If \code{FALSE}, matching only happens when
- dimensions differ, and in that case the species must be in identical
- order in both.}
+ \item{match.force}{Force matching of column names in data
+ (\code{comm}, \code{x}) and labels in \code{tree}. If \code{FALSE},
+ matching only happens when dimensions differ (with a warning or
+ message). The order of data must match to the order in \code{tree}
+ if matching by names is not done.}
\item{relative}{Use distances relative to the height of combined tree.}
\item{\dots}{Other arguments passed to functions (ignored).}
}
@@ -99,8 +100,17 @@
\author{Jari Oksanen}
-\seealso{ \code{\link{taxondive}} is something very similar from
-another world. }
+\seealso{
+ Function \code{treedive} is similar to the phylogenetic
+ diversity function \code{\link[picante]{pd}} in \pkg{picante}, but
+ excludes tree root if that is not needed to connect species. Function
+ \code{treedist} is similar to the phylogenetic similarity
+ \code{\link[picante]{phylosor}} in \pkg{picante}, but excludes
+ unneeded tree root and returns distances instead of similarities.
+
+ \code{\link{taxondive}} is something very similar from another world.
+}
+
\examples{
## There is no data set on species properties yet, and therefore
## the example uses taxonomy
More information about the Vegan-commits
mailing list