[Phylobase-commits] r128 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 28 11:29:19 CET 2008


Author: jombart
Date: 2008-02-28 11:29:19 +0100 (Thu, 28 Feb 2008)
New Revision: 128

Modified:
   pkg/R/subset.R
Log:
Fixed the subseting of a phylo4 using foo[a_character_vector].


Modified: pkg/R/subset.R
===================================================================
--- pkg/R/subset.R	2008-02-27 15:37:59 UTC (rev 127)
+++ pkg/R/subset.R	2008-02-28 10:29:19 UTC (rev 128)
@@ -52,13 +52,17 @@
 # '[' operator
 ###############
 ## phylo4
-setMethod("[","phylo4", 
+setMethod("[","phylo4",
           function(x, i) {
 
               if(missing(i)) i <- TRUE
 
               oldlab <- labels(x)
-              newlab <- oldlab[i]
+              if(is.character(i)){
+                  newlab <- i
+              } else {
+                  newlab <- oldlab[i]
+              }
               tip.include <- match(newlab, oldlab)
               res <- subset(x, tips.include=tip.include)
 



More information about the Phylobase-commits mailing list