update_pb | R Documentation |
Function to update the progress of a simple progress bar
update_pb(pb, value)
pb |
Name of the progress bar to update, previously initialised with |
value |
Level of progress of the bar |
Prints the progress bar with the new value and returns an object of the S4 class simple.progess.bar
containing:
message |
A string representing the message to be printed together with the bar |
bar |
The progress bar |
percentage |
Progress in percentage |
length |
Length of the progress bar (integer) |
remaining |
Character representing the remaining operations |
done |
Character representing the operations already completed |
style_msg |
Styling of |
style_bar |
Styling of |
style_perc |
Styling of |
Telarico, Fabio Ashtar
# 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') } # 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) } }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.