I need to make a matrix from the Baseball dataset ( contains the ID of players who played on a certain team in a certain year). New matrix should indicate how many players played on several teams.
For example, teams ATL and BAL and we write in this box all the players who played on both the first and second teams. In this way we get a symmetric matrix.
But I still don't understand how I can go through all the teams in pairs from the dataset to record the number of players for each pair of teams
Like this: