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, ...)Other Conversions from Node:
as.dendrogram.Node()
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.;"