Quantcast
Channel: How to add progress bar inside dplyr chain in R - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by ACNB for How to add progress bar inside dplyr chain in R

$
0
0

This is a solution that uses cli::cli_progress_bar inside rowwise(). .env is a dplyr variable that has the current environment (inside rowwise), you need to pass its parent to cli_progress_update.

x <- tibble::tribble(  ~a,  1,  2,  3,  4,  5,  6,  7)cli::cli_progress_bar("Some progress", total = 7)y <- x |>  dplyr::rowwise() |>  dplyr::mutate(b = (function(x){    Sys.sleep(50/100)    cli::cli_progress_update(.envir =parent.env(.env))    x  })(a))

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>