Description Usage Arguments Value Examples
This function calls the error()
function to display an error if the
specified condition is false. If a message is not specified then a generic
message is displayed.
1 2 3 4 5 6 7 8 |
condition |
(boolean) The condition to check. |
... |
(character) message to be displayed or written to file. |
level |
(integer, optional) The level of the message, from 1 to 10. Default: 1. |
msg_level |
(integer, optional) The maximum level of messages to output.
Default: set in the option |
msg_types |
(character, optional) The type to write or display. Must
either NULL or one or more from "INFO", "WARNING" or "ERROR". Default: set
in the option |
log_path |
(character, optional) The file path to the text log file. If
set to "", then no logs are written. Default: set in the option
|
If assertion passes then TRUE
is returned. This allows you to make
multiple assertions separated by &
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Not run:
# Use assert() to create conditional timed errors
x <- 1
assert(x > 0, "Condition is true so this error is not shown")
assert(x < 0, "Condition is false so this error is shown")
# As with error() a level can be set
assert(x < 0, "This level 2 error is not shown by default", level = 2)
# Set default level in options to determine what is shown
options(msgr.level = 2)
assert(x < 0, "This is a level 2 error, so is shown now", level = 2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.