Behaviour of case_when with numeric(0)

Viewed 248

I have a problem understanding how dplyr::case_when works. Here with this pretty simple line :

library(tidyverse)
case_when(TRUE ~ 50,
          FALSE ~ numeric(0))

I get numeric(0) while obviously, TRUE is TRUE and so it should send back 50. Besides, FALSE is FALSE so it should never send back numeric(0). I have not the problem if I write :

case_when(TRUE ~ 50,
      FALSE ~ NaN)

Where I get 50, which is right. What do I miss ?

0 Answers
Related