我在 dplyr
链中运行以下的 case_when
:
open_flag = case_when (
open_flag == 0 & (click_flag > 0 | mirror_flag > 0) ~ 1,
TRUE ~ open
)
以上所有变量均为 int
类型。然而,我收到了这个错误信息:
在 names(message) <- vtmp: ! 'names' attribute [1] must be the same length as the vector [0] 中出现错误。
我找到了这篇文章(dplyr::case_when() inexplicably returns names(message) <- `*vtmp*` error),发现了这个问题。尽管我并不完全理解这个问题,所以我未能为我的 case_when()
应用解决方案!
注意:我可以通过使用 ifelse()
来解决这个问题,但我真的很想知道如何为 case_when()
语句解决它!
TRUE ~ open_flag
吗? - langtang