I have two vectors:
A <- c("RS", "DF", "CE")
B <- c("Porto Alegre - RS", "Brasília - DF", "Fortaleza - CE", "Porto Alegre - RS",
"Acre - AC", "Recife - PE")
and a function:
f <- function(a,b) {
lista <- grep(a,b, fixed = FALSE)
return(lista)
}
mm <- lapply(A, B, FUN = f)
I'm getting the position of the elements from A to B, but I need the elements of B, not the position.
I thought this would work:
B[mm]
But it did not. How do I do this?