[Phylobase-commits] r823 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 31 10:05:11 CET 2010


Author: francois
Date: 2010-12-31 10:05:11 +0100 (Fri, 31 Dec 2010)
New Revision: 823

Modified:
   pkg/R/treewalk.R
Log:
bug fix: tip labels with regexp metacharacters are now matched properly

Modified: pkg/R/treewalk.R
===================================================================
--- pkg/R/treewalk.R	2010-11-24 01:33:22 UTC (rev 822)
+++ pkg/R/treewalk.R	2010-12-31 09:05:11 UTC (rev 823)
@@ -18,9 +18,9 @@
     }
 
     ## match node to tree
-    if (is.character(node)) {
-        ndTmp <- paste("^", node, "$", sep="")
-        irval <- lapply(ndTmp, function(ND) grep(ND, labels(x, type)))
+    if (is.character(node)) {       
+        ndTmp <- paste("^\\Q", node, "\\E$", sep="")
+        irval <- lapply(ndTmp, function(ND) grep(ND, labels(x, type), perl=TRUE))
         irval <- unlist(irval)
     } else if (is.numeric(node) && all(floor(node) == node, na.rm=TRUE)) {
         irval <- match(as.character(node), names(labels(x, type)))



More information about the Phylobase-commits mailing list