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
tidyverse
ordata.table
. - There is no reason to use
case_when
ofifelse
orif_else
here, as there is no need to specify all intervals manually. In this particular case,cut
function, suggested by Andrzej already, is perfect, and it comes from base R only. cut
can be applied on vectors directly, no need to convert todata.frame
or related classes.
Hope this helps.