Description Usage Arguments Value
Throws an error (or calls a user-specified function) if the units are not as expected. If the first element of return.values is x, verify_units(x) returns x when units are as expected, and the function may therefore be chained with other commands.
1 2 | verify_units(x, expected.units, return.values = list(x, NULL),
violation.handler = stop, nounits.handler = warning)
|
x |
character. The object to test for whether it has the expected units. |
expected.units |
character. The expected units as a character [vector]. |
return.values |
list(2). The values to return if units are (1) as expected, or (2) not as expected. Good options are list(x,NULL) and list(TRUE, FALSE). Elements beyond position 2 are ignored. |
violation.handler |
closure. The function to call if the expectation is violated. Good options are stop, warning, message, and function(msg) . |
nounits.handler |
closure. The function to call if x or its elements have no units. Good options are stop, warning, message, and function(msg) . |
If units are as expected, returns return.values[[1]] (by default, x). Otherwise stops on an error (if violation.handler=stop) or returns return.values[[2]].
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.