R/concentration.R

Defines functions concentration

Documented in concentration

#  Party System Indicators - Concentration----

concentration <- function(votes) {
     if (!is.numeric(votes)) {
          stop('Input vector must be numeric')
     }
     if (length(votes) < 2 & is.numeric(votes)) {
          stop('Input vector must have minimal lenght of 2.')
     }
     sum(sort(votes/sum(votes), decreasing = TRUE)[1:2])
}

Try the electoral package in your browser

Any scripts or data that you put into this service are public.

electoral documentation built on June 8, 2025, 11:18 a.m.