I'm looking for a way to find the transition matrix (in R) with probabilities where someone moves. This is how my df looks:
City_year1 City_year2
<fct> <fct>
1 Alphen aan den Rijn NA
2 Tynaarlo NA
3 Eindhoven NA
4 Emmen Emmen
5 Emmen Emmen
6 Schagen Schagen
7 Bergen NA
8 Schagen Schagen
9 Schagen Schagen
10 Amsterdam Rotterdam
# .... with 200.000 more rows
How do I easily create a transition matrix with the probabilities that some one moves from Amsterdam in year 1 to Rotterdam in year 2, based on the data available in this df. Extra info: The number of unique values in year 1 is not necessarily equal to the #unique values in year 2. I have tried to use Markov functions, but without success.
I hope someone can help me!