3
I have a vector of percentages, for example,
v<- c(32.5 , 43.2 , 24.1)
> round(v)
[1] 32 43 24
> sum(round(v))
[1] 99
I want a function that manipulates my surroundings so that it adds up to 100. In other words, I want a function fun
so that sum(fun(v))=100
.
The criterion, of course, has to be so that each coordinate of fun(v)
move as little as possible away from the original values. Anyone knows any method to do this?
http://stackoverflow.com/questions/792460/how-to-round-floats-to-integers-while-preserving-their-sum
– rodrigorgs