3
I have the following vector:
> a
[1] 64.42 66.99 100.39 97.96 97.96 96.26 94.22 92.35 86.05 84.01
I wish that I could generate another vector that grows and decreases monotonically, whatever the increment I choose. The output for this vector with increment 1 would be:
> b
[1] 1 2 3 2 1 -1 -2 -3 -4 -5
The ideal would be not to use a loop.
The 4th and 5th values are equal, so it shouldn’t be the output
1 2 3 2 2 1 0 -1 -2 -3
? (Two values equal to2
, in the same positions.)– Rui Barradas
exact, I’ll edit
– Artur_Indio