[Phylobase-commits] r676 - pkg/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Sep 29 18:07:55 CEST 2009
Author: regetz
Date: 2009-09-29 18:07:54 +0200 (Tue, 29 Sep 2009)
New Revision: 676
Modified:
pkg/R/methods-phylo4.R
Log:
changed edgeLength and edgeLabels to return vector with named elements
for every edge even when some/all values are missing; fixes bug #668.
Modified: pkg/R/methods-phylo4.R
===================================================================
--- pkg/R/methods-phylo4.R 2009-09-29 05:57:47 UTC (rev 675)
+++ pkg/R/methods-phylo4.R 2009-09-29 16:07:54 UTC (rev 676)
@@ -191,11 +191,13 @@
function(x, node) {
## [JR: below, using match for ordering rather than direct character
## indexing b/c the latter is slow for vectors of a certain size]
- elen <- x at edge.length[match(edgeId(x, "all"), names(x at edge.length))]
if (!missing(node)) {
- n <- getNode(x, node)
- elen <- elen[match(n, x at edge[,2])]
+ id <- getEdge(x, node)
+ } else {
+ id <- edgeId(x, "all")
}
+ elen <- x at edge.length[match(id, names(x at edge.length))]
+ names(elen) <- id
return(elen)
})
@@ -344,7 +346,10 @@
function(x) {
## [JR: below, using match for ordering rather than direct character
## indexing b/c the latter is slow for vectors of a certain size]
- x at edge.label[match(edgeId(x, "all"), names(x at edge.label))]
+ id <- edgeId(x, "all")
+ lbl <- x at edge.label[match(id, names(x at edge.label))]
+ names(lbl) <- id
+ return(lbl)
})
setReplaceMethod("edgeLabels", signature(x="phylo4", value="character"),
More information about the Phylobase-commits
mailing list