Tengo un dataframe
de unas 200.000 filas con dos columnas de interés que se llaman Crotal y clas. Usando un ifelse
quiero evaluar la condición de que cuando el Crotal sea == XXXX, me ponga 911, sino, 912. Debo hacer unos 200 cambios en total, pero un ejemplo de lo que hice es:
fd07d912$clas = with(fd07d912, ifelse(Crotal == "ES140000729643", "911",
ifelse(Crotal == "ES140000729647", "911",
ifelse(Crotal == "ES140000124962", "911",
ifelse(Crotal == "ES140000124926", "911",
ifelse(Crotal == "ES140000272780", "911",
ifelse(Crotal == "ES140000388723", "911",
ifelse(Crotal == "ES140000314655", "911",
ifelse(Crotal == "ES140000392312", "911",
ifelse(Crotal == "ES140000463118", "911",
ifelse(Crotal == "ES140000314665", "911",
ifelse(Crotal == "ES140000701390", "911",
ifelse(Crotal == "ES140000124234", "911",
ifelse(Crotal == "ES1400NAB53375", "911",
ifelse(Crotal == "ES140000314656", "911",
ifelse(Crotal == "ES140000314587", "911",
ifelse(Crotal == "ES140000270353", "911",
ifelse(Crotal == "ES1400NAB41239", "911",
ifelse(Crotal == "ES1400NAB40016", "911",
ifelse(Crotal == "ES1400NAB57433", "911",
ifelse(Crotal == "ES1400NAB57414", "911",
ifelse(Crotal == "ES140000388722", "911",
ifelse(Crotal == "ES1400NAB43867", "911",
ifelse(Crotal == "ES1400NAB35997", "911",
ifelse(Crotal == "ES1400NAB56140", "911",
ifelse(Crotal == "ES1400NAB35984", "911",
ifelse(Crotal == "ES1400NAB32775", "911",
ifelse(Crotal == "ES140000124230", "911",
ifelse(Crotal == "ES140000124229", "911",
ifelse(Crotal == "ES1400NAB27635", "911",
ifelse(Crotal == "ES1400NAB52939", "911",
ifelse(Crotal == "ES1400NAB27026", "911",
ifelse(Crotal == "ES1400NAB43886", "911",
ifelse(Crotal == "ES1400NAB29216", "911",
ifelse(Crotal == "ES1400NAB40818", "911",
ifelse(Crotal == "ES1400NAB32789", "911",
ifelse(Crotal == "ES1400NAB43882", "911",
ifelse(Crotal == "ES1400NAB17167", "911",
ifelse(Crotal == "ES1400NAB53018", "911",
ifelse(Crotal == "ES1400NAB34375", "911",
ifelse(Crotal == "ES140000124226", "911",
ifelse(Crotal == "ES1400NAB27058", "911",
ifelse(Crotal == "ES1400NAB26997", "911",
ifelse(Crotal == "ES1400NA991189", "911",
ifelse(Crotal == "ES1400NA980896", "911",
ifelse(Crotal == "ES1400NA980918", "911",
ifelse(Crotal == "ES1400NA981018", "911",
ifelse(Crotal == "ES1400NA962546", "911",
ifelse(Crotal == "ES1400NA962588", "911",
ifelse(Crotal == "ES1400NA090096", "911",
ifelse(Crotal == "ES140000838064", "911",
ifelse(Crotal == "ES140001106309", "911",
ifelse(Crotal == "ES140000830080", "911",
ifelse(Crotal == "ES140000830099", "911",
ifelse(Crotal == "ES140000729633", "911",
ifelse(Crotal == "ES140000729638", "911",
ifelse(Crotal == "ES140001106284", "911",
ifelse(Crotal == "ES140001106256", "911",
ifelse(Crotal == "ES140000729641", "911",
ifelse(Crotal == "ES140000719040", "911",
ifelse(Crotal == "ES140000719050", "911",
ifelse(Crotal == "ES140000719054", "911",
ifelse(Crotal == "ES140000463143", "911",
ifelse(Crotal == "ES140000463055", "911",
ifelse(Crotal == "ES140000463047", "911",
ifelse(Crotal == "ES140000463127", "911",
ifelse(Crotal == "ES140000392289", "911",
ifelse(Crotal == "ES140000392310", "911",
ifelse(Crotal == "ES140000729636", "911",
ifelse(Crotal == "ES140000392304", "911",
ifelse(Crotal == "ES140000388710", "911",
ifelse(Crotal == "ES140000314654", "911",
ifelse(Crotal == "ES140000719034", "911",
ifelse(Crotal == "ES140000388718", "911",
ifelse(Crotal == "ES140000386544", "911",
ifelse(Crotal == "ES140000314636", "911", clas))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
Al ejecutarlo, me sale:
Error: contextstack overflow at line 50
He comprado paréntesis por paréntesis y todos los que abrí están correctamente cerrados. Lo único que se me ocurre es que haya un límite máximo de comparaciones posibles, porque por probar hice menos de 50 y funcionó. También me pregunto si existe alguna otra forma más rápida de hacer lo que necesito.
Alguna idea?