stop_if | R Documentation |
Friendlier messaging functions.
stop_if(.x, .p = isTRUE, msg = NULL) stop_if_any(.l, .p = isTRUE, msg = NULL) stop_if_all(.l, .p = isTRUE, msg = NULL) stop_if_none(.l, .p = isTRUE, msg = NULL) stop_if_not(.x, .p = isTRUE, msg = NULL) warn_if(.x, .p = isTRUE, msg = NULL) warn_if_any(.l, .p = isTRUE, msg = NULL) warn_if_all(.l, .p = isTRUE, msg = NULL) warn_if_none(.l, .p = isTRUE, msg = NULL) warn_if_not(.x, .p = isTRUE, msg = NULL) message_if(.x = NULL, .p = isTRUE, msg = NULL) message_if_any(.l, .p = isTRUE, msg = NULL) message_if_all(.l, .p = isTRUE, msg = NULL) message_if_none(.l, .p = isTRUE, msg = NULL) message_if_not(.x, .p = isTRUE, msg = NULL)
.x |
the element to evaluate. It can be a predicate function (i.e a function returning TRUE). |
.p |
the predicate with the condition to test on |
msg |
the message to return. If NULL (default), the built-in message is printed. |
.l |
the list of elements to evaluate |
## Not run: x <- 12 stop_if(x, ~ .x > 13) stop_if_not(x, is.character) a <- "this is not numeric" warn_if(a, is.character) warn_if_not(a, is.numeric) b <- 20 warn_if( b, ~ . > 10, msg = "Wow, that's a lot of b" ) c <- "a" message_if( c, is.character, msg = "You entered a character element" ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.