Hi all. My topic is related to my inability to perform the following for loop with the purrr package.
I have this vector
vctr <- c("caacute;mara", "capitaacute;n", "intreacute;pido")
and I need this result
c("cámara", "capitán", "intrépido")
I find the function str_replace_all and apply it with a for loop
args_1 <- list('aacute;', 'eacute;', 'iacute;')
args_2 <- list('á','é', 'í')
str_repare <- function(vctr, args_1, args_2){
for(i in seq_along(arg_1)){
vctr <- str_replace_all(vctr, args_1[[i]], args_2[[i]])
}
return(vctr)
}
Surely there is a elegant and smarter way to do it with the purrr package but I could never do it on my own.