I am running the function below, but adist() is not vectorized, so I need to run it using rowwise(). Obviously this is very slow with a large amount of data.
In my scenario, I only have current_text and previous_text, and change is generated from adist() and the "trafos" attribute is extracted.
df <- tibble(current_text = c("A","AB","ABC"),
previous_text = c("","A","AB"),
change = c("II","MI","MMI"))
df <- df %>%
rowwise() %>%
mutate(change = attr(adist(previous_text, current_text, counts=TRUE),"trafos"))
How can I run this as a vectorized function, or the very least as a faster function?
A possible solution: