Created
November 6, 2023 00:28
-
-
Save bohdanszymanik/2019b57bd5396c148bb39d5f04a91e06 to your computer and use it in GitHub Desktop.
From a tibble map a (slow) function over a column to calculate a new column with a progress bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
1:1000 |> | |
as_tibble_col(column_name="some_column") |> | |
select(some_column) |> | |
mutate(some_other_column = map(some_column, function(x){Sys.sleep(1/100);(1/x)}, .progress = list( | |
type = "iterator", | |
format = "Calculating {cli::pb_bar} {cli::pb_percent}", | |
clear = TRUE))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment