I am working on a sleep measure PSQI now. A variable called sleep duration is about how many hours each participant sleeps at night, the value of which can be 6, 7.5, 8, 10, 5, 9, etc. I want to create a NEW column which the values changed to different values based on different ranges. Sleep duration under 5 hours is changed to 3, sleep duration 5~6 hours to 2, 6~7 hours to 1, and longer than 7 hours to 0 (I want to keep the old column of sleep duration with how many hours they sleep at night). I have been looking for information regarding the script, but cannot find exactly what I want to do. I know mutate is to create a new variable, but I don't know how to set the arguments in the parentheses. Could anyone show me how to do that? Thank you in advance!
ID. sleep duration. PSQI value
a. 6.5 1
b 5 2
c. 7.5 0
d. 8 0
e. 5 2
f. 9 0
g. 10 0
h. 6 1
How can I code to get the PSQI value?