messagehandler: Warn if

Description Usage Arguments Examples

Description

Friendlier messaging functions.

Usage

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## 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)

attempt documentation built on May 4, 2020, 1:05 a.m.