How can I add new column

Try base::ifelse() R ifelse() Usage with Examples - Spark By {Examples} (sparkbyexamples.com) or
dplyr::if_else() Vectorised if-else — if_else • dplyr (tidyverse.org)

Also, please make your example reproducible next time with the code you tried.

1 Like