I have a directed dyadic data frame that looks like this.
ccode.a ccode.b year mindist int.a2b
167603 220 570 1976 8.985324 0
624316 781 770 1976 7.914206 0
593896 740 620 1976 9.128673 0
669443 900 660 1976 9.235735 1
323404 434 20 1976 8.764419 0
353101 451 432 1976 5.390160 0
37109 53 700 1976 9.373724 0
624853 790 2 1976 8.949047 0
242472 355 53 1976 9.030233 0
35129 53 350 1976 9.006963 0
481129 600 140 1976 8.377329 0
621802 781 310 1976 8.885368 0
236655 350 600 1976 7.587584 0
192503 290 950 1976 9.636472 1
464722 580 94 1976 9.551535 0
550661 694 42 1976 9.377167 0
585022 712 625 1976 8.586424 0
637007 812 2 1976 8.902645 0
539818 678 572 1976 8.402542 0
690214 950 900 1976 7.859377 1
135804 160 135 1976 6.314121 0
554291 694 811 1976 8.603649 0
496453 620 680 1976 7.565657 0
68160 90 220 1976 9.003781 0
605932 770 482 1976 8.355514 0
509185 640 660 1976 4.873909 0
24928 42 830 1976 9.774045 0
454705 570 666 1976 8.740049 0
92800 100 51 1976 6.631003 1
492025 616 651 1976 7.140152 0
598335 750 663 1976 7.997375 0
485329 615 130 1976 8.951390 0
330093 435 520 1976 8.560956 0
74135 91 570 1976 9.453192 0
465351 580 235 1976 8.989404 1
227129 345 165 1976 9.296795 0
488046 615 696 1976 8.298939 0
381548 483 375 1976 8.325534 0
237750 350 840 1976 9.103709 0
402138 510 265 1976 8.688151 0
372394 475 950 1976 9.798338 0
216445 338 570 1976 8.890926 1
598308 750 660 1976 8.082419 0
613237 775 235 1976 9.100852 0
310790 420 42 1976 8.617836 0
611272 771 696 1976 8.065013 0
183450 235 551 1976 8.739090 0
659939 840 590 1976 8.879307 0
506308 640 70 1976 9.232063 0
188756 290 91 1976 9.120557 1
I want to create a matrix of all of the pairs of ccode.a and ccode.b,
d.sender <- matrix(0, nrow = 192, ncol = 192, dimnames = list(unique(dyad$ccode.a), unique(dyad$ccode.a)))
And then assign the value of int.a2b (I’ll have to do this for a bunch of variables) to the appropriate cell in the matrix. This will be done separately for each year in the data set. Since the data frame is directed dyadic I’ll also have a receiver matrix of the same dimension that that mirrors the sender matrix I’m trying to create now.
If I am correct in understanding what you want, here is one way: