Posts tagged: tilde

2020-04-25When's the case for case_when() ?

Last week I was taking some colleagues through the code for my COVID19 PDF scraping and afterwards one sent me a message asking about a chunk of code that used the dplyr::case_when() function. In particular they wanted to know why case_when() uses the tilde (~)1, which led to a bit more of a generalised conversation about case_when() and how it works. In your script, when you assign the values to the entity and position columns inside your case_when() call why do you use ~ rather than = or <-?