progress line in map

Hi,
I wish to create a function replacing basic purr::map with progress line (similar to the one in furrr for paralllel).
I found an example on the web, but it does not print the progress line and I can't figure out why:

s=letters
names(s)=LETTERS


map_df_progress <- function(.x, .f, ..., .id = NULL) {
  .f <- purrr::as_mapper(.f, ...)
  pb <- progress::progress_bar$new(total = length(.x), force = TRUE)
  
  f <- function(...) {
    pb$tick()
    .f(...)
  }
  purrr::map_df(.x, f, ..., .id = .id)
}

map_df_progress(s, ~ str_c(., "asxde"))

you're asking it to do so little work, it completes in a fraction of a second, so you don't notice the progressbar.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.