R language tip: Learn dplyr’s case_when() function

preview_player
Показать описание
In this second episode of Do More with R, Sharon Machlis, director of Editorial Data & Analytics at IDG Communications, shows how dplyr's case_when() function helps avoid a lot of nested ifelse statements

Follow TECH(talk) for the latest tech news and discussion!
------------------------------­----
Рекомендации по теме
Комментарии
Автор

You mentioned you didn't know why the last condition was "TRUE".
That's the case because a condition of "TRUE" is always going to evaluate to TRUE, and therefore acts as the catch-all for the final condition.

RonBertino
Автор

this helped me a lot!
thank you.
But I still wonder if we need to 'vectorize' all the values before being able to use case_when every time we have a "chr/fctr" variable

biialeaal
Автор

It seems not to work properly when you have a logical vector at the right hand side.

alvaromorales