as {phylobase} | R Documentation |
Translation functions to convert between phylobase objects
(phylo4
or phylo4d
), and objects used by other
comparative methods packages in R: ape
objects (phylo
,
multiPhylo
), ade4
objects (phylog
), and to
data.frame
representation.
as(object, class)
object
phylo4
, phylo
or
phylog
, or tree and data object of class phylo4d
.class
tree
should
be coerced (e.g., "phylo4"
or "data.frame"
).
Coerce from one object class to another using
as(object, "class")
, where the object
is of the old class
and the returned object is of the new class "class"
. The
as
function examines the class of object
and the new
"class"
specified to choose the proper conversion without
additional information from the user. Conversions exist for
combinations:
phylobase
to phylobase
formats:
as(object, "phylo4d")
as(object, "phylo4")
extractTree
, but in this case, no error message is produced.phylobase
to ape
formats:
as(object, "phylo")
phylo
. If data are dropped during the conversion from a phylo4d
object, a warning message is produced.as(object, "multiPhylo")
multiPhylo
.ape
to phylobase
formats:
as(object, "phylo4")
phylo
and returns an object of class phylo4
.as(object, "phylo4d")
phylo
and returns an object of class phylo4d
, with empty data.as(object, "multiPhylo4")
multiPhylo
and returns an object of class multiPhylo4
. phylobase
to ade4
formats:
as(object, "phylog")
phylo4
and returns an object of class phylog.phylobase
format to data.frame
:
as(object, "data.frame")
phylo4
or phylo4d
and returns an object of class data.frame
, with data included in the case of phylo4d
.Ben Bolker, Thibaut Jombart, Marguerite Butler, Steve Kembel
generic as
, phylo4
,
phylo4d
, extractTree
, the original
phylog
from the ade4
package and
as.phylo
from the ape
package.
tree.owls <- read.tree(text="(((Strix_aluco:4.2,Asio_otus:4.2):3.1,Athene_noctua:7.3):6.3,Tyto_alba:13.5);") ## 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")