stop_if {attempt}R Documentation

Warn if

Description

Friendlier messaging functions.

Usage

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)

Arguments

.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 .x or .l. Default is isTRUE.

msg

the message to return. If NULL (default), the built-in message is printed.

.l

the list of elements to evaluate

Examples

## 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)

[Package attempt version 0.3.1 Index]