I have a dataframe as below, with 47 States and the average market fare of traveling by airplane between those two states (the order of State 1 and State 2 does not matter). How can I convert this to a 47x47 matrix, where each row and column is a State Name, and the value at each location is the Mean Market Fare between those two states.
First 6 Rows:
State 1 State 2 Mean Market Fare
1 Alabama Alabama 263.3752
2 Alabama Arizona 320.5036
3 Alabama Arkansas 288.9775
4 Alabama California 352.6983
5 Alabama Colorado 282.6864
6 Alabama Connecticut 266.9601
Last 6 Rows:
State 1 State 2 Mean Market Fare
1097 Washington Wyoming 286.9314
1098 West Virginia Wisconsin 302.7769
1099 West Virginia Wyoming 493.2000
1100 Wisconsin Wisconsin 251.3333
1101 Wisconsin Wyoming 285.3015
1102 Wyoming Wyoming 275.9800