call_conditionally {fritools} | R Documentation |
Call a Function Conditionally
Description
whoami 1.3.0 uses things like
system("getent passwd $(whoami)", intern = TRUE)
which I can not tryCatch
, as it gives no error nor warning.
So this function returns a fallback if the condition given is not
TRUE
.
Usage
call_conditionally(f, condition, fallback, ..., harden = FALSE)
Arguments
f |
The function passed to |
condition |
An expression. |
fallback |
See Description. |
... |
arguments passed to |
harden |
Value
The return value of f
or fallback
.
See Also
Other call functions:
call_safe()
Examples
call_conditionally(get_package_version,
condition = TRUE,
args = list(x = "fritools"),
fallback = "0.0")
call_conditionally(get_package_version,
condition = FALSE,
args = list(x = "fritools"),
fallback = "0.0")
call_conditionally(get_package_version,
condition = TRUE,
args = list(x = "not_there"),
harden = TRUE,
fallback = "0.0")
[Package fritools version 4.3.0 Index]