| nexml_get {RNeXML} | R Documentation |
Get the desired element from the nexml object
Description
Get the desired element from the nexml object
Usage
nexml_get(
nexml,
element = c("trees", "trees_list", "flat_trees", "metadata", "otu", "taxa",
"characters", "characters_list", "namespaces"),
...
)
Arguments
nexml |
a nexml object (from read_nexml) |
element |
the kind of object desired, see details. |
... |
additional arguments, if applicable to certain elements |
Details
"tree" an ape::phylo tree, if only one tree is represented. Otherwise returns a list of lists of multiphylo trees. To consistently receive the list of lists format (preserving the hierarchical nature of the nexml), use
treesinstead."trees" returns a list of lists of multiphylo trees, even if all trees are in the same
treesnode (and hence the outer list will be of length 1) or if there is only a single tree (and hence the inner list will also be of length 1. This ensures a consistent return type regardless of the number of trees present in the nexml file, and also preserves any hierarchy/grouping of trees."flat_trees" a multiPhylo object (list of ape::phylo objects) Note that this method collapses any hierarchical structure that may have been present as multiple
treesnodes in the original nexml (though such a feature is rarely used). To preserve that structure, usetreesinstead."metadata"Get metadata from the specified level (default is top/nexml level)
"otu" returns a named character vector containing all available metadata. names indicate
property(orrelin the case of links/resourceMeta), while values indicate thecontent(orhreffor links)."taxa" alias for otu
For a slightly cleaner interface, each of these elements is also defined as an S4 method
for a nexml object. So in place of get_item(nexml, "tree"), one could use get_tree(nexml),
and so forth for each element type.
Value
return type depends on the element requested. See details.
See Also
Examples
comp_analysis <- system.file("examples", "comp_analysis.xml", package="RNeXML")
nex <- nexml_read(comp_analysis)
nexml_get(nex, "trees")
nexml_get(nex, "characters_list")