
set
or inc
during a loop to change the display. Note that you are
not allowed to decrease the value of the bar. If you call
these function without setting any of the arguments the
bar is simply redrawn with the current value. For
errorhandling use error
and have a look at the
example below. You can globally change the behavior of
all bars by setting the option
options(BBmisc.ProgressBar.style)
either to
options(BBmisc.ProgressBar.width)
. By default this
is getOption("width")
.makeProgressBar(min = 0, max = 100, label = "",
char = "+")
numeric(1)
]
Minimum value, default
is 0.numeric(1)
]
Maximum value, default
is 100.character(1)
]
Label shown in
front of the progress bar. Note that if you later set
msg
in the progress bar function, the message will
be left-padded to the length of this label, therefore it
should be at least as long acharacter(1)
]
A single character
used to display progress in the bar. Default is
ProgressBar
]. A list with following
functions:function(value,
msg=label)
]function(value, msg=label)
]function(clear=FALSE)
]function(e)
]tryCatch
to
properly display error messages below the bar. See the
example.bar <- makeProgressBar(max=5, label="test-bar")
for (i in 0:5) {
bar$set(i)
Sys.sleep(0.2)
}
bar <- makeProgressBar(max=5, label="test-bar")
for (i in 1:5) {
bar$inc(1)
Sys.sleep(0.2)
}
# display errors properly (in next line)
f = function(i) if (i>2) stop("foo")
bar <- makeProgressBar(max=5, label="test-bar")
for (i in 1:5) {
tryCatch ({
f(i)
bar$set(i)
}, error=bar$error)
}
Run the code above in your browser using DataLab