What's the best way to transform the following data into an array/ into an origin-destination matrix?
My original data somewhat look like the ones below:
The first column is the origin, second column is the destination, and the third column is the number of trips. (Please note that the dataset is also not sorted yet.)
The output should be the data from the third column only (number of trips), and arranged in a way that the rows is ordered with respect to the first column (origin) and the columns is ordered with respect to the second column (destination) of the original dataframe.
The output should look like the ones below (only the ones highlighted in yellow):
My data is already loaded in Matlab. Excel screenshots are for illustration purposes only of how I want to manipulate the data.
Best Answer