This function computes the total number, the average number having the same value of a categorical variable and the number of individuals a partition.
same_pairs(partition, attribute, stat)
Arguments
partition: A partition (vector)
attribute: A vector containing the values of the attribute
stat: The statistic to compute : 'avg_pergroup' for the average, 'sum_pergroup' for the sum, 'sum_perind' and 'avg_perind' for the number of ties per individual each individual has in its group.
Returns
The statistic chosen in stat
Examples
p <- c(1,2,2,3,3,4,4,4,5)at <- c(0,1,1,1,1,0,0,0,0)same_pairs(p,at,'avg_pergroup')