This surprised me:
x = 1:2 dplyr::case_when( length(x)==1 ~ x, length(x)==2 ~ x ) #>  2 2
It seems that
case_when is evaluating each RHS and using that to determine the length of the result. Is there a way to avoid this? In my actual use case I am always expecting a character(1) so I subscript the result but it feels pretty hacky. It's easy to imagine situations where not every RHS is a valid expression in the current environment.