I have the following table :
| Date | Values | Days |
|---|---|---|
| 12/28/2020 | 0.485002 | 0 |
| 12/29/2020 | 0.385427 | 1 |
| 12/30/2020 | 0.323091 | 2 |
| 12/31/2020 | 0.19967 | 3 |
| 1/4/2021 | 0.009859 | 4 |
| 1/5/2021 | -0.15653 | 0 |
| 1/6/2021 | -0.26286 | 1 |
| 1/7/2021 | -0.18659 | 2 |
| 1/8/2021 | -0.18207 | 3 |
| 1/22/2021 | 1.077845 | 0 |
| 1/25/2021 | 1.300135 | 1 |
| 1/26/2021 | 1.390824 | 2 |
| 1/27/2021 | 1.256247 | 3 |
| 1/28/2021 | 1.09526 | 4 |
The column "Days" shows the number of days since the last time the "Values" sign switched from positive to negative and vice versa.
How can I create the column "Days" using "dplyr mutate" in R ?
Thanks.