Question:
I have a data frame of multiple columns. I want to create a new colomn called second.indicator with the following :second.indicator == -1 if il.count.description + un.count.description > elle.count.description + une.count.description
second.indicator == 0 if il.count.description + un.count.description) == elle.count.description + une.count.description
else second.indicator == 1
the output is many error messages : ‘second.indicator’ not found / Error: unexpected ‘}’ in ” }”
Answer:
You cannot useif
-statements inside mutate
like that (for multiple reasons); instead you could use case_when
:If you have better answer, please add a comment about this, thank you!