# \donttest{
################### A for looping approach ################
pb <- progress()
for (i in 1:100) {
run_progress(pb, actual = i, sleep = 0.01)
}
################### An apply family approach ##############
pb <- progress(max = 10)
foo <- function(...){
run_progress(pb, ...)
rnorm(100) %>% mean()
}
(a <- sapply(1:10, FUN = foo, sleep = 0.05))
######## A purrr functional programming approach ##########
foo2 <- function(...){
run_progress(pb2, ...)
rnorm(100) %>% mean()
}
pb2 <- progress(max = 10000,
style = 4,
leftd = "",
char = ".",
rightd = "!")
b <- purrr::map_dbl(1:10000, foo2, text = "Progress bar for sampling")
hist(b)
# }
Run the code above in your browser using DataLab