I have a pass traffic data which shows the pass traffic between Members, here’s the sample dataset
It shows the Interactions between Members in consecutive rows. I want to count that interactions, and obtain a new dataset which shows how many interactions occured between Members for Each Member, the direction doesn’t matters
For example:
between 26 and 11 = X
between 26 and 27 = Y
I just can’t figure it out which function I can use and how can I write a code for this calculation. Thanks
You could use the
rollaplyfunction from thezoopackage to find all interactions. The frequency of these interactions could be calculated usingtable. (I assume your object is calleddat.)The result:
The lower triangular part of the matrix contains zeros only since the direction does not matter.
If you are not interested in interactions between the same values, use the following command: