Range of attribute in groups
This function computes the sum or the average range of an attribute for groups in a partition.
range_attribute(partition, attribute, stat)
partition
: A partition (vector)attribute
: A vector containing the values of the attributestat
: The statistic to compute : 'avg_pergroup' for the average per group and 'sum_pergroup' for the sum of the rangesThe statisic chosen in stat
p <- c(1,2,2,3,3,4,4,4,5) at <- c(3,5,23,2,1,0,3,9,2) range_attribute(p,at,'avg_pergroup')