To read from Newick, you can use the ape package, and convert the resulting phylo object to a data.tree structure.

ToNewick(node, heightAttribute = DefaultPlotHeight, ...)

Arguments

node

The root Node of a tree or sub-tree to be converted

heightAttribute

The attribute (field name, method, or function) storing or calculating the height for each Node

...

parameters that will be passed on the the heightAttributeName, in case it is a function

See also

Other Conversions from Node: as.dendrogram.Node()

Examples

data(acme)
ToNewick(acme)
#> [1] "((New_Software:50,New_Accounting_Standards:50)Accounting:50,(New_Product_Line:50,New_Labs:50)Research:50,(Outsource:50,Go_agile:50,Switch_to_R:50)IT:50)Acme_Inc.;"
ToNewick(acme, heightAttribute = NULL)
#> [1] "((New_Software,New_Accounting_Standards)Accounting,(New_Product_Line,New_Labs)Research,(Outsource,Go_agile,Switch_to_R)IT)Acme_Inc.;"
ToNewick(acme, heightAttribute = function(x) DefaultPlotHeight(x, 200))
#> [1] "((New_Software:100,New_Accounting_Standards:100)Accounting:100,(New_Product_Line:100,New_Labs:100)Research:100,(Outsource:100,Go_agile:100,Switch_to_R:100)IT:100)Acme_Inc.;"
ToNewick(acme, rootHeight = 200)
#> [1] "((New_Software:100,New_Accounting_Standards:100)Accounting:100,(New_Product_Line:100,New_Labs:100)Research:100,(Outsource:100,Go_agile:100,Switch_to_R:100)IT:100)Acme_Inc.;"