Read NeXML files into various R formats

nexml_read(x, ...)

# S3 method for character
nexml_read(x, ...)

# S3 method for XMLInternalDocument
nexml_read(x, ...)

# S3 method for XMLInternalNode
nexml_read(x, ...)

Arguments

x

Path to the file to be read in. An XML::XMLDocument-class or XMLNode-class

...

Further arguments passed on to xmlTreeParse

Examples

# file f <- system.file("examples", "trees.xml", package="RNeXML") nexml_read(f)
#> A nexml object representing: #> 1 phylogenetic tree block(s), where: #> block 1 contains 2 phylogenetic tree(s) #> 0 character block(s), #> 5 taxonomic units in 1 block(s) #> Taxa: species 1, species 2, species 3, species 4, species 5 ... #> Metadata annotations: #> 0 at top level #> 0 in block 1 at otu level #> #> NeXML generated by RNeXML using schema version: 0.9 #> Size: 139.1 Kb
if (FALSE) # may take > 5 s # url url <- "https://raw.githubusercontent.com/ropensci/RNeXML/master/inst/examples/trees.xml" nexml_read(url)
#> Error in UseMethod("nexml_read"): no applicable method for 'nexml_read' applied to an object of class "function"
# character string of XML str <- paste0(readLines(f), collapse = "") nexml_read(str)
#> A nexml object representing: #> 1 phylogenetic tree block(s), where: #> block 1 contains 2 phylogenetic tree(s) #> 0 character block(s), #> 5 taxonomic units in 1 block(s) #> Taxa: species 1, species 2, species 3, species 4, species 5 ... #> Metadata annotations: #> 0 at top level #> 0 in block 1 at otu level #> #> NeXML generated by RNeXML using schema version: 0.9 #> Size: 139.1 Kb
# XMLInternalDocument library("httr") library("XML") x <- xmlParse(content(GET(url)))
#> Error in as.character(url): cannot coerce type 'closure' to vector of type 'character'
nexml_read(x)
#> Error in nexml_read(x): object 'x' not found
# XMLInternalNode nexml_read(xmlRoot(x))
#> Error in xmlRoot(x): object 'x' not found