excel - Matrix with boolean values from a list of paired observations -
in below spreadsheet, cell values represent id person. person in column likes person in column b, may not mutual. so, in first row data, person 1 likes 2. in second row data person 1 likes 3.
a b 1 2 1 3 2 1 2 4 3 4 4 1 i'm looking way have 4 x 4 matrix entry of 1 in (i,j) indicate person likes person j , entry of 0 indicate don't. example above should after performing task:
1 2 3 4 1 0 1 1 0 2 1 0 0 1 3 0 0 0 1 4 1 0 0 0 so, reading first row of matrix interpret this: person 1 not person 1 (cell value = 0), person 1 likes person 2 (cell value = 1), person 1 likes person 3 (cell value =1), person 1 not person 4 (cell value = 0)
note order of pairing matter [4 2] not equal [2 4].
how done?
assuming existing data in a1:b6, in a10 enter:
=countifs($a$1:$a$6, row()-9,$b$1:$b$6, column()) this return 1 or 0 depending on whether person 1 likes person 1. don't 0. uses row()-9 return 1 , column() return 1 find match.
copy formula on 4 columns , down 4 rows , row()-9 , column() formula return appropriate values check countifs() formula matching pair.

personally, if had , matrix of indeterminate size, stick these formulas on second tab, starting @ a1 , use row() don't have adjust 9. 1 off on same tab, check results, above fine.
Comments
Post a Comment