Create tree structures from hierarchical data, and traverse the
tree in various orders. Aggregate, cumulate, print, plot, convert to and from
data.frame and more. Useful for decision trees, machine learning, finance,
conversion from and to JSON, and many other applications.
An R package to manage hierarchical data and tree structures
data.tree is to hierarchical data what data.frame is to tabular data. You can create tree structures from hierarchical data, and use the utility methods to traverse the tree in various orders. You can also aggregate, print, convert to and from data.frame, and apply functions to your tree data.
News
All changes to data.tree are documented here.
Version 0.7.8
FIX: wrong export of S3
Version 0.7.7
IMPROVE: if an attribute of a node has n dimensions, then Get will return an array of dim n+1, with the names of the first dimension being equal to the node names (thanks to Chris Hammil)
FIX: fieldsAll now doesn't simplify (thanks to Vaclav Slimacek)
Version 0.7.6
IMPROVE: plot now also works for trees with a single root node (thx to Pierre Neuvial)
IMPROVE: ellipsis parameters are not passed to DiagrammeR for plotting (#109)
FIX: Dependency on DiagrammeR (>= 1.0.0) explicitly stated (#111)
IMPROVE: Allow tibble in FromDataFrameNetwork and FromDataFrameTable (#115)
Version 0.7.5
IMPROVE: namesNotUnique parameter in as.Node.phylo (#106)
FIX: fixed incompatibility issue with DiagrammeR (#110)
Version 0.7.4
IMPROVE: print now has an explicit arg pruneFun
FIX: partykit tests now pass
FIX: DESCRIPTION now in line with latest changes from CRAN (rmarkdown declared)
FIX: Skipped tests in testMethods included
Version 0.7.3
FIX: Various typos in documentation
Version 0.7.2
Upgrade to R 3.4.x and newest package versions.
FIX: plot: global graph attributes now work (#88)
FIX: typo in vignette data.tree vignette('applications', package = "data.tree")
FIX: warnings in as.dendrogram
FIX: warnings in sample code for Do
FIX: as.data.frame created warnings for values that were of length 0
Version 0.7.0
ADD: ToDiagrammeRGraph to convert to a DiagrammeR graph object
REMOVE: ToGraphViz (replaced with ToDiagrammeRGraph, to support the latest features in the DiagrammeR package). You can still get the dot representation by using DiagrammeR::generate_dot(ToDiagrammeRGraph(node))
CHANGE: plot.Node 's last parameter is now 'graph', and not 'engine' anymore.
FIX: minor typos fixed
Version 0.6.2
ADD: new Distance function to measure distance from one Node to another in the same tree
Version 0.6.1
IMPROVE: FromListSimple now accepts subclasses of lists (#79)
IMPROVE: FromDataFrameTable now supports tibbles (#89)
IMPROVE: print.Node and as.data.frame.Node now also work for node fields with length > 1 (#81)
FIX: print.Node and as.data.frame.Node now also work if some Nodes have the same name as some fileds (#82)
REMOVE: node$FindNode, and node$Navigate are now deprecated. Use FindNode(node, ...) and Naviate(node, ...) instead
REMOVE: node$Sort, node$Prune, and node$Revert are now deprecated. Use Sort(node, ...), Prune(node, ...) and Revert(node, ...) instead
Version 0.5.0
IMPROVE: Performance improvement for many functions. For example, as.Node roughly by factor 4 for large dataset (#74)
CHANGE: by default, as.data.frame.Node (and derivatives) do not format anymore (use the format parameter if you want to format)
IMPROVE: Allow the possibility to keep only some fields when converting to list using as.list.Node (#76)
FromDataFrameTable (#77)
FIX: now also works if there is only the pathString column
IMPROVE: pathString can now also be a factor (or any other type convertible to character)
Version 0.4.0
IMPROVE: as.Node.data.frame and FromDataFrameTable now support paths containing reserved words (#65)
CHANGE: Node$new now checks that names are not reserved names. As a consequence, many conversions to Node now contain a check parameter.
IMPROVE: Climb is now much faster when climbing by name (#71)
IMPROVE: As a result of #71, many other functions are much faster, e.g. FromDataFrameTable (#72)
Version 0.3.7
ADD: Traverse can now also take custom function as a traversal argument
ADD: Navigate method
ADD: as.Node.BinaryTree Convert SplittingNode from party package to data.tree (#6)
ADD: as.Node.party Convert party class from partykit package to data.tree (#6)
Version 0.3.6
FIX: GetDefaultTooltip now also works for attributes which are functions
FIX: GetAttribute now returns attributes with length 0 (e.g. an empty list)
ADD: Sort, Revert and Prune are now also available in traditional format (e.g. Prune(node, pruneFun))
FIX: FromListSimple: Empty lists now become empty nodes (#59)
IMPROVE: FromListSimple: Unnamed list elements are now also converted (#61)
IMPROVE: documentation of Aggregate
IMPROVE: Check type when setting Node$parent and Node$children (#63)
Version 0.3.5
FIX: minor correction in documentation
Version 0.3.4
FIX: minor correction in documentation
Version 0.3.3
CHANGE: Renamed Find method to FindNode, in order to avoid masking from base
FIX: upgrade to latest version of treemap package
FIX: a few typos in documentation
Version 0.3.2
ADD: FromListExplicit now interprets character vectors as a list of nodes (#58)
Version 0.3.1
IMPROVE: as.list.Node
now generates auto name if unique name is not available (#54)
now has warn arg, warning if source data contains reserved names
now also imports fiels with names equal to reserved names (e.g. count), they will be renamed (to e.g. count2)
CHANGE: node$leaves now returns a list even when called on a leaf itself
ADD: Find method to find a single Node in a (sub-)tree (#52)
Version 0.3.0 Pine Tree
REMOVE: Removed the cacheAttribute parameter from Aggregate and Cumulate (they were confusing, even to me. Use Do instead to manually store aggregate values in the tree)
ADD: plot function (see ?plot.Node)
ADD: ToDataFrameTypeCol to export e.g. the path to columns by level in columns: ToDataFrameTypeCol(acme)
ADD: Node$AddSibling
ADD: Node$RemoveAttribute now contains a mandatory parameter so that it can be used if the node does not have the attribute to be removed.
ADD: Get works on methods without args
IMPROVE: FormatFixedDecimal and FormatPercent work for NULL values
IMPROVE: Documentation
FIX: Aggregate will not return attribute from callee anymore, but always aggregate children attributes
FIX: Removed ... parameter from ToListExplicit and ToListSimple
FIX: Clone was adding empty children list, which caused a series of problems (#44)
FIX: Cloning a subtree does not keep reference to un-cloned parent anymore (#49)
FIX: print with limit parameter ignored formatter (#43)
FIX: cannot rename to int, e.g. acme$Do(function(x) x$name <- x$position) (#53)