I am running the following case_when
inside a dplyr
chain:
open_flag = case_when (
open_flag == 0 & (click_flag > 0 | mirror_flag > 0) ~ 1,
TRUE ~ open
)
All variables above are of type int
. However, I get back this message:
Caused by error in names(message) <- vtmp: ! 'names' attribute [1] must be the same length as the vector [0]
I have found this post (dplyr::case_when() inexplicably returns names(message) <- `*vtmp*` error) that identified the issue. I don't fully understand the issue, and so I failed to apply a solution for my case_when()
above!
Note: I can solve the problem by using ifelse()
, but I really wonder how to solve it for the case_when()
statement!