I have a dataframe that looks like this:
| name | manager |
|---|---|
| John | Bill |
| Bill | David |
| David | Sarah |
| Sarah |
name = c("John","Bill","David","Sarah")
manager = c("Bill","David","Sarah","")
df = data.frame(name,manager)
(Sarah is the top of the ladder) I'm just trying to do a simple lookup to pull in John's manager's manager (David). Ideally I would like a recursive loop in R that will run through my dataset and create an output that lists all the managers above each person such as this:
| name | manager | output |
|---|---|---|
| John | Bill | Bill_David_Sarah |
| Bill | David | David_Sarah |
| David | Sarah | Sarah |
| Sarah |
Also please note, my data is not ordered in such a manner, and a manager can manage multiple people, its not one to one. Any help would be appreciated thanks!
