data.tree: General Purpose Hierarchical Data Structure

> library(data.tree)
> data("mushroom")

バージョン: 0.4.0


関数名 概略
Aggregate Aggregate child values of a 'Node', standalone or in traversal.
AreNamesUnique Test whether all node names are unique.
Climb Find a 'Node' by provided criteria.
ClimbByAttribute Find a 'Node' by provided criteria.
Clone Clone a tree (creates a deep copy)
CreateRandomTree Create a tree for demo and testing
CreateRegularTree Create a tree for demo and testing
Cumulate Cumulate values among siblings
DefaultPlotHeight Calculates the height of a 'Node' given the hight of the root.
Do Executes a function an a set of nodes
FormatFixedDecimal Format a Number as a Decimal
FormatPercent Format a Number as a Percentage
Get Traverse a Tree and Collect Values
GetAttribute Get an attribute from a Node.
GetPhyloNr Determine the number a 'Node' has after conversion to a phylo object
NODE_RESERVED_NAMES_CONST Names that are reserved by the Node class.
Node Create a 'data.tree' Structure With 'Nodes'
Set Traverse a Tree and Assign Values
SetFormat Set a formatter function on a specific node
ToNewick Write a 'data.tree' structure to Newick notation
Traverse Traverse a tree or a sub-tree
acme Sample Data: A Simple Company with Departments
as.Node Convert an object to a 'data.tree' data structure
as.Node.data.frame Convert a 'data.frame' to a 'data.tree' structure
as.Node.dendrogram Convert a 'dendrogram' to a data.tree 'Node'
as.Node.list Convert a nested 'list' structure to a 'data.tree' structure
as.Node.phylo Convert a 'phylo' object from the ape package to a 'Node'
as.data.frame.Node Convert a 'data.tree' structure to a 'data.frame'
as.dendrogram.Node Convert a 'Node' to a 'dendrogram'
as.igraph.Node Convert a 'data.tree' structure to an igraph network
as.list.Node Convert a 'data.tree' structure to a list-of-list structure
as.phylo.Node Convert a 'Node' to a phylo object from the ape package.
averageBranchingFactor Calculate the average number of branches each non-leaf has
data.tree data.tree: Hierarchical Data Structures
isLeaf Check if a 'Node' is a leaf
isNotLeaf Check if a 'Node' is not a leaf
isNotRoot Check if a 'Node' is not a root
isRoot Check if a 'Node' is the root
mushroom Sample Data: Data Used by the ID3 Vignette
print.Node Print a 'Node' in a human-readable fashion.

as.dendrogram

> as.dendrogram()

as.Node

Arguments

  • x
  • ...
> fileName <- system.file("extdata", "portfolio.csv", package="data.tree")
> pfodf <- read.csv(fileName, stringsAsFactors = FALSE)
> 
> pfodf$pathString <- paste("portfolio", 
+                           pfodf$AssetCategory, 
+                           pfodf$AssetClass, 
+                           pfodf$SubAssetClass, 
+                           pfodf$ISIN, 
+                           sep = "/")
> pfo <- as.Node(pfodf)
> pfo
                             levelName
1  portfolio                          
2   ¦--Cash                          
3   ¦   ¦--CHF                      
4   ¦   ¦   °--LI0015327682        
5   ¦   ¦--EUR                      
6   ¦   ¦   °--LI0214880598        
7   ¦   °--USD                      
8   ¦       °--LI0214880689         
9   ¦--Fixed Income                  
10  ¦   ¦--EUR                      
11  ¦   ¦   ¦--Sov. and Corp. Bonds
12  ¦   ¦   ¦   ¦--LU0243957825   
13  ¦   ¦   ¦   °--LU0408877412   
14  ¦   ¦   ¦--Em. Mkts Bonds      
15  ¦   ¦   ¦   °--LU0376989207   
16  ¦   ¦   °--High Yield Bonds    
17  ¦   ¦       °--GB00B42R2118    
18  ¦   °--USD                      
19  ¦       °--High Yield Bonds     
20  ¦           °--LU0292585030     
21  ¦--Equities                      
22  ¦   ¦--Switzerland              
23  ¦   ¦   ¦--CH0011037469        
24  ¦   ¦   °--DE0008490145        
25  ¦   ¦--Euroland                 
26  ¦   ¦   ¦--NL0000303600        
27  ¦   ¦   ¦--IE00B60SWX25        
28  ¦   ¦   ¦--FR0000120271        
29  ¦   ¦   ¦--DE0008404005        
30  ¦   ¦   ¦--IT0000072618        
31  ¦   ¦   °--BE0003793107        
32  ¦   ¦--US                       
33  ¦   ¦   ¦--US4581401001        
34  ¦   ¦   ¦--US0378331005        
35  ¦   ¦   ¦--US4370761029        
36  ¦   ¦   ¦--US5949181045        
37  ¦   ¦   °--US7427181091        
38  ¦   ¦--UK                       
39  ¦   ¦   °--GB00BH4HKS39        
40  ¦   ¦--Japan                    
41  ¦   ¦   °--IE00B42Z5J44        
42  ¦   ¦--Australia                
43  ¦   ¦   °--IE00B5377D42        
44  ¦   °--Emerging Markets         
45  ¦       °--LU0040507039         
46  °--Alternative Investments       
47      ¦--Real Estate               
48      ¦   °--Eurozone             
49      ¦       °--LU0216734045     
50      ¦--Hedge Funds               
51      ¦   °--LU0462954800         
52      °--Commodities               
53          °--LU0239752628
> GNI2010$pathString <- paste("world", GNI2010$continent, GNI2010$country, sep = "/")
Error in paste("world", GNI2010$continent, GNI2010$country, sep = "/"): object 'GNI2010' not found
> n <- as.Node(GNI2010[,])
Error in as.Node(GNI2010[, ]): object 'GNI2010' not found
> print(n, pruneMethod = "dist", limit = 20)
function () 
{
    stop("This function should not be called directly")
}
<environment: namespace:dplyr>

mushroom

> data("mushroom")
> mushroom %>% {
+   class(.) %>% print()
+   dplyr::glimpse(.)
+ }
[1] "data.frame"
Observations: 5
Variables: 4
$ color     <fctr> red, brown, brown, green, red
$ size      <fctr> small, small, large, small, large
$ points    <fctr> yes, no, yes, no, no
$ edibility <fctr> toxic, edible, edible, edible, edible