#install.packages("data.tree") library(data.tree) kool <- Node$new("Tallinna 37. Keskkool") klass2b <- kool$AddChild("klass2b") klass2b$AddChild("Jaagup") klass2b$AddChild("Andi") klass2b$AddChild("Jüri") klass2a=kool$AddChild("klass2a") klass2a$AddChild("Hannes") print(kool) print(kool, limit=4) kool$height kool$count kool$totalCount kool$children kool$averageBranchingFactor kool$leaves ?Prune kool$Get("klass2b", filterFun = isLeaf) #Prune(kool, pruneFun=isLeaf) ToDataFrameNetwork(kool) kool$klass2b$count kool$klass2b$children kool$klass2b$children[[1]]$name sapply(kool$klass2b$children, function(x)x$path) kool$klass2b$children$Andi$pikkus <- 155 print(kool, "pikkus") plot(kool) SetNodeStyle(kool$klass2b, style="filled", fillcolor="lightgreen", penwidth="5px") plot(kool) plot(as.dendrogram(kool), center=TRUE) library(igraph) plot(as.igraph(kool)) plot(as.igraph(kool, directed = TRUE, direction="climb")) plot(as.igraph(kool$klass2b)) library(networkD3) simpleNetwork(ToDataFrameNetwork(kool, "name")) radialNetwork(ToListExplicit(kool, unname=TRUE)) ToDataFrameNetwork(kool, "pikkus") ToDataFrameTypeCol(kool, "pikkus") print(kool, "level", "name") kool$Get("name", filterFun = function(x)nchar(x$name)==4) kool$Do(function(x)x$pikkus=x$count, filterFun=isNotLeaf) print(kool, "pikkus")