Created
February 8, 2022 08:39
-
-
Save jvieroe/8864f0e3f25407121ec2f1d26c40a25f to your computer and use it in GitHub Desktop.
progress bar in for loops
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) | |
library(future) | |
library(furrr) | |
library(gapminder) | |
library(svMisc) | |
# ------ create dummy dataset | |
df <- gapminder::gapminder | |
table(df$year) | |
# ----- get vector that the loop is defined by | |
unique_years <- unique(df$year) | |
unique_years | |
# ----- define length of vector, "how many i's?" | |
max_element <- length(unique_years) | |
# ----- run loop | |
for (i in seq_along(unique_years)) { | |
svMisc::progress(i, max_element) | |
Sys.sleep(0.5) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment