Re: [R] D'Hondt method

2009-02-04 Thread Thomas Steiner
very cool, easier than I thought... (although I am not fully familiar with sapply() and friends) quick reality-check (no proof!) at http://icon.cat/util/elections/isuHqUyDYh shows that the results coincide: votes <- c(42201,38635,247736,170627,48236,117151,61379,35889,92321) dHont(c("BGLD","KTN",

Re: [R] D'Hondt method

2009-02-04 Thread Carlos J. Gil Bellosta
Hello, I believe that a "productionized" version of the following would do: dHont <- function( candidates, votes, seats ){ tmp <- data.frame( candidates = rep( candidates, each = seats ), scores = as.vector(sapply( votes, function(x) x / 1:seats ))