Closed tylerlittlefield closed 4 years ago
This PR adds hp_datatree with the goal of making {hierplane} compatible with {data.tree}. Also updated the README a bit. Some examples below:
hp_datatree
library(hierplane) library(data.tree) acme <- Node$new("Acme Inc.") accounting <- acme$AddChild("Accounting") software <- accounting$AddChild("New Software") standards <- accounting$AddChild("New Accounting Standards") research <- acme$AddChild("Research") newProductLine <- research$AddChild("New Product Line") newLabs <- research$AddChild("New Labs") it <- acme$AddChild("IT") outsource <- it$AddChild("Outsource") agile <- it$AddChild("Go agile") goToR <- it$AddChild("Switch to R") acme %>% hp_datatree() %>% hierplane()
library(hierplane) library(data.tree) library(yaml) yaml <- " name: r4fun tyler: name: Tyler job: Data Scientist species: Human toulouse: name: Toulouse job: Systems Engineer species: Cat toulouse: name: Toulouse job: Systems Engineer species: Cat ollie: name: Ollie job: Database Administrator species: Dog lucas: name: Lucas job: R Programmer species: Rabbit " yaml %>% yaml.load() %>% as.Node() %>% hp_datatree() %>% hierplane()
library(hierplane) library(data.tree) fileName <- system.file("extdata", "useR15.csv", package="data.tree") useRdf <- read.csv(fileName, stringsAsFactors = FALSE) useRdf$pathString <- paste("useR", useRdf$session, useRdf$room, useRdf$speaker, sep="|") useRtree <- as.Node(useRdf, pathDelimiter = "|") useRtree %>% hp_datatree( attributes = "presentation" ) %>% hierplane( width = "auto", height = "auto" )
library(hierplane) library(data.tree) library(jsonlite) "https://raw.githubusercontent.com/tyluRp/catfacts/master/renv.lock" %>% read_json() %>% as.Node() %>% hp_datatree( attributes = c( "Version", "URL", "Repository" ) ) %>% hierplane()
This PR adds
hp_datatree
with the goal of making {hierplane} compatible with {data.tree}. Also updated the README a bit. Some examples below:Creating a tree the {data.tree} way
Creating a tree from YAML
Creating a tree from CSV
Creating a tree from JSON