stop_if {xpectr}R Documentation

Simple side effect functions

Description

[Experimental]

If the `condition` is TRUE, generate error/warning/message with the supplied message.

Usage

stop_if(condition, message = NULL, sys.parent.n = 0L)

warn_if(condition, message = NULL, sys.parent.n = 0L)

message_if(condition, message = NULL, sys.parent.n = 0L)

Arguments

condition

The condition to check. (Logical)

message

Message. (Character)

Note: If NULL, the `condition` will be used as message.

sys.parent.n

The number of generations to go back when calling the message function.

Details

When `condition` is FALSE, they return NULL invisibly.

When `condition` is TRUE:

stop_if()

Throws error with the supplied message.

warn_if()

Throws warning with the supplied message.

message_if()

Generates message with the supplied message.

Value

Returns NULL invisibly.

Author(s)

Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk

Examples

# Attach packages
library(xpectr)
## Not run: 
a <- 0
stop_if(a == 0, "'a' cannot be 0.")
warn_if(a == 0, "'a' was 0.")
message_if(a == 0, "'a' was so kind to be 0.")

## End(Not run)

[Package xpectr version 0.4.3 Index]