Hi, I want to generate a code to automatically replace/clean names from one tibble (clean_db) based on the correct names from another tibble (Provincia). The code is the following:
str_replace(clean_db$provincia, paste(str_sub(clean_db$provincia, 1, 2),
".+",
str_sub(clean_db$provincia, -2),
sep = ""),
as.character(as_tibble(str_extract(Provincia$descripcion,
paste(str_sub(clean_db$provincia, 1, 2),
".+",
str_sub(clean_db$provincia, -2),
sep = ""))) %>% drop_na()))
The clean_db tibble has 532 obs. The thing is, the replacement argument picks all the strings in Provincia tibble, but what I need is to check the string in Provincia tibble (which is a 25 obs.) and just pick one string and then go to the next line of the clean_db tibble and do the same thing, so in this way the replacement just pick one string from Provincia tibble and then keep doing it for the entire clean_db tibble.
Thanks a lot,
KM