'Roll vector so max value is centered and order of values relative to it stay the same
How can I roll a vector so the max value is in the middle and the order of values relative to it stay the same?
If the length of the vector is even, then just put it in the mean value: n/2
If I have:
vec <- c(0, 2, 4, 3, 1, 8)
I want to return:
3 1 8 0 2 4
Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
