I have the following data frame 'x'
id,item,volume
a,c1,2
a,c2,3
a,c3,2
a,c4,1
a,c5,4
b,c6,6
b,c1,2
b,c3,1
b,c2,6
b,c4,4
c,c2,5
c,c8,6
c,c9,2
d,c1,1
e,c3,7
e,c2,3
e,c1,2
e,c9,5
e,c4,1
f,c1,7
f,c3,1
The first column is the id of a customer, the second column is the id of an item that customer bought and the third column is the number of those items bought. I'm trying to create a co-occurrence matrix which is a square matrix with 8 rows and columns, 8 being the number of distinct items.
n = length(unique(x$cid))
Could this be done through a SAC paradigm? For every id, I need to update the above matrix by adding +1 for every combination. For example for user 'b' with items c1,c2,c3,c4,c6, the 1st row in the matrix for columns 2,3,4 & 6 should be incremented by 1 and so on for all users. I'm unable to cast it into this framework. Any help much appreciated.