You can use dplyr::case_when()
dplyr::case_when()
Also, for guidelines about how to properly ask homework related questions here, please read our homework policy.