I have a data frame which looks like the following
Order Location
1 X
1 NA
2 Y
2 Y
2 NA
3 Z
3 NA
4 Z
I want to replace the NA in column Location with locations pertaining to the same order number. The final result should be
Order Location
1 X
1 X
2 Y
2 Y
2 Y
3 Z
3 Z
4 Z
How do I achieve this in R using dplyr or any other packages? Thank you.