[Adephylo-commits] r40 - in pkg: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Nov 26 16:12:14 CET 2008
Author: jombart
Date: 2008-11-26 16:12:14 +0100 (Wed, 26 Nov 2008)
New Revision: 40
Modified:
pkg/R/utils.R
pkg/man/miscUtils.Rd
Log:
Bugfix to .tipToRoot: added an argument to return the root.
Modified: pkg/R/utils.R
===================================================================
--- pkg/R/utils.R 2008-11-26 14:58:26 UTC (rev 39)
+++ pkg/R/utils.R 2008-11-26 15:12:14 UTC (rev 40)
@@ -18,7 +18,7 @@
## root: to root node; could be computed inside the function,
## but will often be computed outside, once and for all.
##
-.tipToRoot <- function(x, tip, root){
+.tipToRoot <- function(x, tip, root, include.root=FALSE){
E <- x$edge
path <- NULL
curNode <- tip
@@ -27,7 +27,9 @@
path <- c(path, curNode)
} # end while
- path <- getnodes(x, path[-length(path)]) # exclude the root
+ if(!include.root) {
+ path <- getnodes(x, path[-length(path)]) # exclude the root
+ }
return(path)
} # end tipToRoot
@@ -109,7 +111,7 @@
## main computations
- allPathToRoot <- lapply(allTips, function(i) .tipToRoot(x, i, root))
+ allPathToRoot <- lapply(allTips, function(i) .tipToRoot(x, i, root, include.root=TRUE))
names(allPathToRoot) <- allTips
allPath1 <- allPathToRoot[as.character(t1)]
Modified: pkg/man/miscUtils.Rd
===================================================================
--- pkg/man/miscUtils.Rd 2008-11-26 14:58:26 UTC (rev 39)
+++ pkg/man/miscUtils.Rd 2008-11-26 15:12:14 UTC (rev 40)
@@ -13,12 +13,16 @@
}
\usage{
-.tipToRoot(x, tip, root)
+.tipToRoot(x, tip, root, include.root=FALSE)
}
\arguments{
\item{x}{A valid tree of class \linkS4class{phylo4}.}
\item{tip}{An integer identifying a tip by its numbers.}
- \item{root}{An integer identifying the root of the tree by its numbers.}
+ \item{root}{An integer identifying the root of the tree by its
+ numbers.}
+ \item{include.root}{a logical stating whether the root must be
+ included as a node of the path from tip to root (TRUE), or not
+ (FALSE, default).}
}
\value{
\code{.tipToRoot}: a vector of named integers identifying nodes.\cr
More information about the Adephylo-commits
mailing list