I am currently running some functions on large data sets for which each operation takes a long time to execute.
To see the progress of my calculations, it would be handy to print the iterations/percentage of completed calculations. With loops, this can be easily done.
However, is it possible to have something similar working for vectorized functions or or pre-defined functions without actually making changes to the source code of those functions?
Example data:
generate_string
taken from here : Generating Random Strings
generate_string <- function(n = 5000) {
a <- do.call(paste0, replicate(5, sample(LETTERS, n, TRUE), FALSE))
paste0(a, sprintf("%04d", sample(9999, n, TRUE)), sample(LETTERS, n, TRUE))
}
x <- generate_string(10000)
y <- generate_string(10000)
Example function to be monitored:
(i.e. printing the percentage completed):
library(stringdist)
# amatch will find for each element in x the index of the most similar element in y
ind <- amatch(x,y, method = "jw", maxDist = 1)