I have a data frame containing a column for Time and next it a column named phase. Values in the column named phase range from 0 - 1. I would like to reassign the values that fall into a range a new value (1,2,3,...).
If a phase is between 0 and less than 0.125 it should equal a 1
if a phase is between 0.125 and less than 0.25 it should equal 2
if a phase is between 0.25 and less than 0.375 it should equal 3
...
...
if a phase is between 0.875 and 1 it should equal 8
date phase
1 2019-07-24 00:02:40 0.7255562
2 2019-09-19 09:03:21 0.6679123
3 2019-06-25 13:18:33 0.7622182
4 2019-04-04 15:21:06 0.9772049
5 2019-09-26 04:22:48 0.9107171
6 2019-04-14 07:42:06 0.3203704
I am assuming the best way to go about this is an if else statement or a for loop, however I am struggling getting something that even runs.
I am working in R studio.
Aucun commentaire:
Enregistrer un commentaire