stop_if: Stop execution on TRUE

Description Usage Arguments Details Value Examples

Description

Stop execution on TRUE

Usage

1
stop_if(expr, error)

Arguments

expr

Expression to evaluate

error

Error message to return

Details

This is a convenience function that stops the running code when expr is TRUE and displays the text in error.

Value

An object of class 'error'

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Using dontrun as the function returns an error
## Not run: 
a <- 2
stop_if(a==2, "a is equal to 2")

# This is just a short form of
if(a == 2){
    stop("a is equal to 2")
}

## End(Not run)

pedrostrusso/prlib documentation built on May 5, 2019, 11:01 p.m.