Please familiarise yourself with the following:
Also, please use meaningful thread titles instead of "Need help" or something like that. That will significanty improve chance of answers from the menbers.
Now that moderation stuff is done, I'll share the following pointers, without providing any direct solution.
- You absolutely do not need
tidyverseordata.table. - There is no reason to use
case_whenofifelseorif_elsehere, as there is no need to specify all intervals manually. In this particular case,cutfunction, suggested by Andrzej already, is perfect, and it comes from base R only. cutcan be applied on vectors directly, no need to convert todata.frameor related classes.
Hope this helps.