case_when only 2 unique values shown

Hi,
I try to use the case_when function in the Bellabeat dataset:
sleepday <- sleepday %>%
mutate(SleepPatterns = factor(case_when(TotalMinutesAsleep < 420 ~ "Undersleep",
TotalMinutesAsleep >= 420 & TotalMinutesAsleep <= 540 ~ "Normal sleep",
TotalMinutesAsleep > 540 ~ "Oversleep"), levels=c("Under sleep", "Normal sleep", "Over sleep")))
The issue is that I see some values over 700 in the TotalMinutesAsleep column however only two unique values are returned (NA and "Normal Sleep"). Any idea what might happen?
Many thanks
Panos

Please post a small data set that illustrates the problem. Filter sleepday to include the rows you want, and possibly drop irrelevant columns, and then post the output of using dput() on the filtered data set. If the filtered data set is called DF, post the output of

dput(DF)

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.