(Updated 2019/03) A Mistake Caused by Ifelse and Factors

Updated 2019/03: Just as I expected at the end of this post two years ago, a new package vctrs has come out to handle type stability. You can watch Hadley’s talk at the RStudio conference 2019, in which he talked about base ifelse being too free and dplyr::if_else being too strict. I made a mistake in one of the data processing script I wrote in R a while ago and figured I should share the story with everybody.