Hey @livjos! You might be interested in some of the functions in the dplyr
package:
-
(oops, I thought you had H or D in a separate column), anddplyr::recode()
can directly translate values of a column (eg."D"
becomes"Diseased"
) -
dplyr::case_when()
can create values for a column based on conditions in one or more other columns.
If you have a peak at the documentation links for those functions, they'll show you some great examples of what you want to do. In this case, you might want to use case_when()
with the base endsWith()
function, which will return TRUE
or FALSE
depending on whether each row ends with the supplied suffix.
If you get stuck using them, come back with a reproducible example (reprex
) and we can help you out more