# A single bar in a loop
pb<-create_pb(length=10, print=TRUE)
for(i in 1:10){
cat('This is the number',i,'\n')
pb<-update_pb(pb,i)
Sys.sleep(.3)
cat(pb$value,'operation completed\n')
}
# \donttest{
# Two progress bars in multiple loops
pb_for<-create_pb(length=3, print=TRUE,colour='red')
for(i in 1:3){
cat('This is the number',i,'\n')
pb_for<-update_pb(pb_for,i)
Sys.sleep(1)
pb_while<-create_pb(length=i, print=TRUE,colour='blue')
while(pb_while$value<i){
cat('This is a subtask \n')
pb_while<-update_pb(pb_while,pb_while$value+1)
Sys.sleep(1)
}
}
# }
Run the code above in your browser using DataLab