Time is a very valuable thing for individual and organization, and nowadays we need to do our job in a very efficient manner weather due to the criticality of the task our to the time constraint. In this short article I’ll try to reproduce a single HTA table into many different kinds of outputs, and by doing that I’m trying to achieve two things:
R is a statistcal programming language.
You can visit this site to learn how to install it - R installtion.
We’ll simply create the HTA once in spread sheet. Please note that the data should be in table format as below.
| level1 | Level2 |
|---|---|
| 1.Fill Kettle | 1.1.Take to tap |
| 1.Fill Kettle | 1.2.Turn on water |
| 1.Fill Kettle | 1.3.Check level |
| 1.Fill Kettle | 1.4.Turn off water |
| 1.Fill Kettle | 1.5.Take to socket |
| 2.Switch Kettle on | 2.1 Plug into socket |
| 2.Switch Kettle on | 2.2 Turn on power |
| 3.Check water in kettle | NA |
| 4.Switch Kettle off | NA |
| 5.Pour water | 5.1 Lift kettle |
| 5.Pour water | 5.2 Direct spout |
| 5.Pour water | 5.3 Tilt kettle |
| 5.Pour water | 5.4 Replace kettle |
Note that we didn’t put the main task (0) yet.
Now we’ll import our HTA table to R.
library(readxl) # tp read excel files
library(data.tree) # to convert table to node like shape
library(networkD3) # to create network
library(collapsibleTree) # to create tree
HTA <- read_excel("~/R/HTA.xlsx") # read the spreadsheet into R
HTA$pathString <- paste("Boil a kettle", # adding the main task
HTA$level1, # adding the path string to our HTA table
HTA$Level2,
sep = "/")
HTAtree <- as.Node(HTA) # convert the table to nodeHTAtree levelName
1 Boil a kettle
2 ¦--1.Fill Kettle
3 ¦ ¦--1.1.Take to tap
4 ¦ ¦--1.2.Turn on water
5 ¦ ¦--1.3.Check level
6 ¦ ¦--1.4.Turn off water
7 ¦ °--1.5.Take to socket
8 ¦--2.Switch Kettle on
9 ¦ ¦--2.1 Plug into socket
10 ¦ °--2.2 Turn on power
11 ¦--3.Check water in kettle
12 ¦ °--NA
13 ¦--4.Switch Kettle off
14 ¦ °--NA
15 °--5.Pour water
16 ¦--5.1 Lift kettle
17 ¦--5.2 Direct spout
18 ¦--5.3 Tilt kettle
19 °--5.4 Replace kettle
plot(HTAtree)SetGraphStyle(HTAtree, rankdir = "TB")
SetEdgeStyle(HTAtree, arrowhead = "vee", color = "grey35", penwidth = 2)
SetNodeStyle(HTAtree, style = "filled,rounded", shape = "box", fillcolor = "GreenYellow",
fontname = "helvetica", tooltip = GetDefaultTooltip)
SetNodeStyle(HTAtree$`3.Check water in kettle`, fillcolor = "LightBlue", penwidth = "5px")
plot(HTAtree)HTAnet <- ToDataFrameNetwork(HTAtree, "name")
simpleNetwork(HTAnet[-3], fontSize = 12)collapsibleTreeSummary(HTA, hierarchy = c("level1", "Level2"), root = "0 Boil kettle")Christoph Glur for creating the data.tree package and for his toutrial on how to use it.