tree_string <- "(((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3):6.3,Tyto_alba:13.5);"
tree.owls <- ape::read.tree(text=tree_string)
## round trip conversion
tree_in_phylo <- tree.owls # tree is a phylo object
(tree_in_phylo4 <- as(tree.owls,"phylo4")) # phylo converted to phylo4
identical(tree_in_phylo,as(tree_in_phylo4,"phylo"))
## test if phylo, and phylo4 converted to phylo are identical
## (no, because of dimnames)
## Conversion to phylog (ade4)
as(tree_in_phylo4, "phylog")
## Conversion to data.frame
as(tree_in_phylo4, "data.frame")
## Conversion to phylo (ape)
as(tree_in_phylo4, "phylo")
## Conversion to phylo4d, (data slots empty)
as(tree_in_phylo4, "phylo4d")
Run the code above in your browser using DataLab