'R code for mapping one ID to multiple Names?

I am trying to see if there is a way to make a table output what names are listed for what IDs. For example:

Column A: Name Column B: ID Column C: Random Data Column D: Random Data

There are multiple reoccuring IDs (lets say 12345) that has the names Jon, Bob, Allen, Matt, etc mapped to it. I want to know what IDs are linked to Jon then also find out what other names are linked to the same ID that is linked to Jon.

So I would like the output to be:

Column A: Jon (My key name) Column B: ID (All IDs linked to Jon) Column C: Other name linked to same ID as Jon Column D: Other name linked to same ID as Jon etc etc

Column X: Random Data Column y: Random Data

so:

Picture



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source