[Adephylo-commits] r23 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 25 14:04:52 CET 2008


Author: jombart
Date: 2008-11-25 14:04:51 +0100 (Tue, 25 Nov 2008)
New Revision: 23

Modified:
   pkg/R/utils.R
Log:
Fixes for naming output of sp.tips.


Modified: pkg/R/utils.R
===================================================================
--- pkg/R/utils.R	2008-11-25 12:57:15 UTC (rev 22)
+++ pkg/R/utils.R	2008-11-25 13:04:51 UTC (rev 23)
@@ -1,7 +1,7 @@
 ##########
 # sp.tips
 ##########
-sp.tips <- function(phy, tip1, tip2){
+sp.tips <- function(phy, tip1, tip2, useTipNames=FALSE){
     if(!require(phylobase)) stop("phylobase package is not installed")
 
     ## conversion from phylo, phylo4 and phylo4d
@@ -66,18 +66,26 @@
     allPath2 <- allPathToRoot[as.character(t2)]
 
     res <- lapply(1:length(allPath1), function(i) pathTwoTips(allPath1[[i]], allPath2[[i]]) )
-    names(res) <- paste(tip1,tip2,sep="-")
 
+    if(useTipNames) {
+        names(res) <- paste(names(t1), names(t2), sep="-")
+    } else {
+        names(res) <- paste(t1,t2,sep="-")
+    }
+
     return(res)
 } # end sp.tips
 
 
 
 # examples
-phy <- as(rtree(15),"phylo4")
-plot(phy,show.n=T)
-tip1 <- "t1"
-tip2 <- "t2"
+# source("/home/master/dev/adephylo/pkg/R/utils.R")
+## phy <- as(rtree(15),"phylo4")
+## plot(phy,show.n=T)
+## tip1 <- "t1"
+## tip2 <- "t2"
 
 
-sp.tips(phy, "t1", "t2")
+## sp.tips(phy, "t1", "t2")
+## sp.tips(phy, rep(1,15), 1:15)
+## sp.tips(phy, rep(1, 15), 1:15, TRUE)



More information about the Adephylo-commits mailing list