0

I'm having trouble understanding how to create a data.tree from a data frame. I have a data frame with two columns:

  1. EmpID
  2. SupervisorUserID

Code:

OfficeOrg <- read_csv("hierarchy")
OfficeOrg$pathString <- paste("Root", 
OfficeOrg$SupervisorEmpID, OfficeOrg$EmpID, sep = "/")

RptTree <- as.Node(OfficeOrg)

The sample data has 25 rows. By inspecting the data, I can see that there are five levels. That is to say, I expect the RptTree object to show EmpIDs grouped under SupervisorEmpID to a depth of five.

Root
 |_TopLevelSupervisor
      |_SecondLevelSupervisor
           |_ThirdLevelSupervisor
                 |_Employee

Instead, I see only three levels. The root, one for each SupervisorEmpID and the employees.

Root
  |_Supervisor
      |_ Employee

The tree isn't being built by recursing through all levels. Usually this means that I'm staring something in the face, but not recognizing it.

What am I missing?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
Charles Knell
  • 117
  • 1
  • 9
  • It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Dec 12 '18 at 21:15

1 Answers1

0

After searching off and on for several days, I found the solution to my problem at this Stack Overv Flow post: data.tree nodes through Id's

Charles Knell
  • 117
  • 1
  • 9