I am trying to create a new variable in df that takes the mode of a variable with the same ID number. I want the output to look like this:
ID X MODE
1 3 2
1 2 2
1 2 2
2 1 3
2 2 3
2 1 3
2 3 3
2 3 3
3 5 5
3 5 5
Any suggestions?