failwith {plyr}R Documentation

Fail with

Description

Modify a function so that it returns a default value when there is an error.

Usage

failwith(default = NULL, f, quiet = FALSE)

Arguments

default default value
f function
quiet

Value

a function

Author(s)

Hadley Wickham <h.wickham@gmail.com>

See Also

try_default

Examples

f <- function(x) if (x == 1) stop("Error!") else 1
## Not run: 
f(1)
f(2)
## End(Not run)

safef <- failwith(NULL, f)
safef(1)
safef(2) 

[Package plyr version 0.1.9 Index]