Skip to content

Commit 1a0e6ac

Browse files
author
guangchuang yu
committed
bug fixed of get.tree for data.frame
1 parent e46d615 commit 1a0e6ac

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

R/method-get-tree.R

+5-4
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,21 @@ setMethod("get.tree", signature(object="phylo"),
6565
function(object, ...) {
6666
return(object)
6767
})
68-
68+
6969
##' @rdname get.tree-methods
7070
##' @exportMethod get.tree
7171
setMethod("get.tree", signature(object="data.frame"),
7272
function(object, ...) {
73+
edge <- object[, c("parent", "node")]
7374
i <- which(edge[,1] != 0 & edge[,1] != edge[,2])
7475
edge <- edge[i, ]
7576
edge.length <- object[i, "branch.length"]
76-
tip.label <- object[object[, "isTip"], "label"]
77-
phylo <- list(edge = edge,
77+
tip.label <- object[object[, "isTip"], "label"]
78+
phylo <- list(edge = as.matrix(edge),
7879
edge.length = edge.length,
7980
tip.label = tip.label)
8081

81-
node.label <- object[!object[, "isTip"], "label"]
82+
node.label <- object[!object[, "isTip"], "label"]
8283
if (!all(is.na(node.label))) {
8384
phylo$node.label <- node.label
8485
}

0 commit comments

Comments
 (0)