Description Usage Arguments Details Value Examples
This function calls the error()
function to display an error if the
variable's values are not valid file or directory paths.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | assert_file(
x,
level = 1,
msg_level = getOption("msgr.level"),
msg_types = getOption("msgr.types"),
log_path = getOption("msgr.log_path")
)
assert_dir(
x,
level = 1,
msg_level = getOption("msgr.level"),
msg_types = getOption("msgr.types"),
log_path = getOption("msgr.log_path")
)
assert_readable(
x,
level = 1,
msg_level = getOption("msgr.level"),
msg_types = getOption("msgr.types"),
log_path = getOption("msgr.log_path")
)
assert_writeable(
x,
level = 1,
msg_level = getOption("msgr.level"),
msg_types = getOption("msgr.types"),
log_path = getOption("msgr.log_path")
)
assert_url(
x,
level = 1,
msg_level = getOption("msgr.level"),
msg_types = getOption("msgr.types"),
log_path = getOption("msgr.log_path")
)
|
x |
(any) The variable to check. |
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
|
The following validations can be checked:
assert_file()
: 'x' must be an existing file
assert_dir()
: 'x' must be an existing directory
assert_readable()
: 'x' must be a readable directory or file
assert_writeable()
: 'x' must be a writeable directory or file
assert_url()
: 'x' must be a valid URL
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 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## Not run:
# No error
assert_file(system.file("DESCRIPTION", package = "msgr"))
# Error
assert_file("no-such-file.txt")
# No error
assert_dir(R.home())
# Error
assert_dir("no-such-directory")
# No error
assert_readable(R.home())
# Error
assert_readable("no-such-directory")
# No error
assert_writeable(Sys.getenv("HOME"))
# Error
assert_writeable("no-such-directory")
# No error
assert_url("https://www.google.com")
# Error
assert_url("no-such-site")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.