Reputation: 43
I would like to see a progress bar while loop is running. I have a data set with 300,000 variables and takes forever. I would like to use a function or package like 'progress' to show how long the loop will take. With the code below is this possible.
i <- 1
while (i <= nrow(df)) {
if (is.na.data.frame(df$case_no[i]))
df$case_no[i] <- df$case_number[i]
i <- i + 1
}
Upvotes: 4
Views: 5181
Reputation: 826
Can do like this
x <- rep(x = NA, times = 100)
pb <- txtProgressBar(0, length(x), style = 3)
for(i in 1:length(x)) {
setTxtProgressBar(pb, i)
x[i]
Sys.sleep(time = 1)
}
close(pb)
Upvotes: 8