I am trying to clean up the strings in a column in my R dataframe but ran into a problem where I am running too many ifelse statements (it is telling me that the maximum is 50). What is the alternative to this? Put simply I want to detect a string in one column and give an output in another column, however there are more than 50 titles. what is the alternative to this method?
for example:
ifelse(str_detect(titles$program_name, "¿sabías que...?") == TRUE, "¿sabías que...?",
ifelse(str_detect(titles$program_name, "12 corazones|12 hearts|2 hearts") == TRUE, "12 Corazones",
ifelse(str_detect(titles$program_name, " al lado del otro muro") == TRUE, "Al Otro Lado Del Muro",
ifelse(str_detect(titles$program_name, "a toda gloria") == TRUE, "A Toda Gloria",
ifelse(str_detect(titles$program_name, "acceso vip") == TRUE, "Acceso VIP",
ifelse(str_detect(titles$program_name, "afv") == TRUE, "AFV",
ifelse(str_detect(titles$program_name, "al rojo vivo") == TRUE, "Al Rojo Vivo",
ifelse(str_detect(titles$program_name, "alma awards") == TRUE, "ALMA Awards",
ifelse(str_detect(titles$program_name, "amar es primavera") == TRUE, "Amar es primavera",
ifelse(str_detect(titles$program_name, "anónima|anonima|anonymized") == TRUE, "Anonima",
ifelse(str_detect(titles$program_name, "astrologia") == TRUE, "Astrologia",
ifelse(str_detect(titles$program_name, "billboard") == TRUE, "Premios Billboard",
ifelse(str_detect(titles$program_name, "bajo el mismo cielo") == TRUE, "Bajo El Mismo Cielo",
ifelse(str_detect(titles$program_name, "bella calamidades") == TRUE, "Bella Calamidades",
ifelse(str_detect(titles$program_name, "betty") == TRUE, "Betty en NY",
ifelse(str_detect(titles$program_name, "buscando mi ritmo") == TRUE, "Buscando Mi Ritmo",
### this continues on for more than 50 titles
how can i do this so as to avoid the error?