Warning message: In if (DataIfElse$Cost == "R") { : the condition has length > 1 and only the first element will be used

You are not using the same code as FJCC suggested. You have changed | to ||, and used Df$... instead of just column name inside case_when. You need not give dataframe name inside case_when.

Also, | and || are not same. The longer reports only one boolean based on 1st element, and the shorter returns a vector of booleans. I posted regarding this a while back, so I'm linking that below.

Hope this helps.

1 Like