I am having trouble building a tree.map from parent/child grouped pairs. Here's my sample data:
SubjectID <- c('101','101','101','102','103','103','103')
parent <- c(1387, 1620, 1743,986,1623,1191,1450)
child<-c(1620,1743,1859 ,1015,1385,1450,1623)
df<-data.frame(SubjectID, parent,child)
I've tried building the tree with tree.map:
df$pathString<- paste("study",df$SubjectID, df$parent, df$child, sep="/") as.Node(df)
The result is:
1 study
2 ¦--101
3 ¦ ¦--1387
4 ¦ ¦ °--1620
5 ¦ ¦--1620
6 ¦ ¦ °--1743
7 ¦ °--1743
8 ¦ °--1859
9 ¦--102
10 ¦ °--986
11 ¦ °--1015
12 °--103
13 ¦--1623
14 ¦ °--1385
15 ¦--1191
16 ¦ °--1450
17 °--1450
18 °--1623
I would like the result to link the parent with child like this:
1 study
2 ¦--101
3 ¦ ¦--1387
4 ¦ ¦ °--1620
5 ¦ ¦ °--1743
6 ¦ ¦ °--1859
9 ¦--102
7 ¦ °--986
8 ¦ °--1015
9 °--103
10 ¦--1623
11 ¦ °--1385
12 ¦--1191
13 ¦ °--1450
14 ¦ °--1623
The blow codes work and gives exactly the same output.