fork_help | R Documentation |
ifelse
.Return different types of objects for TRUE
and FALSE
and return NULL
conditional on the number of TRUE
values.
fork_help()
f0(x, y, n)
fork(x, y, n, na = n)
f1(x, y, n, na = n, err = n)
nll_if(x, ..., d = " ")
nll_ifs(..., .d = " ", .cond = "all")
nll_if_any(..., .d = " ")
nll_if_all(..., .d = " ")
nll_if_none(..., .d = " ")
x |
A logical scalar (if not, |
y , n |
Any valid R object. |
na |
An object of any type for |
err |
Either |
d , .d |
A character scalar delimiter for collapsing objects into scalar character objects. If |
.cond |
A character scalar in |
f0()
: If x
is scalar TRUE
, returns y
. If x
is anything else, returns n
.
fork()
: Evaluates logical scalar or logical vector x
and return an object of the same length as x
where:
TRUE
values of x
are replaced by corresponding values of y
.
FALSE
values of x
are replaced by corresponding values of n
.
NA
values of x
are replaced by na
(unless na = 'err'
, in which case if there are any NA
values in x
, throws an error).
Returns a length-length(x)
atomic object.
f1()
: Error-checked version of f0
. Evaluates and processes logical scalar x
in the following manner:
If x = TRUE
, returns y
.
If x = FALSE
, returns y
.
If x = NA
, returns na
unless na = 'err'
, in which case, an error is thrown.
If x
is neither a logical scalar nor scalar NA
, returns err
unless err = 'err'
, in which case an error is thrown.
nll_if()
: If x
is scalar TRUE
, returns NULL
, otherwise collapses ...
args to a character scalar using delimiter d
and returns the result.
nll_ifs()
: Calls nll_if_none(..., d = .d)
when .cond = 'none'
. Calls nll_if_any(..., d = .d)
when .cond = 'any
. Calls nll_if_all(..., d = .d)
when .cond
takes any other value (including 'all'
)
nll_if_any()
: Returns NULL
if any named ...
argument is scalar TRUE
. Otherwise, returns a message composed of unnamed ...
args collapsed into a character scalar using the delimiter .d
.
nll_if_all()
: Returns NULL
if all named ...
arguments are scalar TRUE
. Otherwise, returns a message composed of unnamed ...
args collapsed into a character scalar using the delimiter .d
.
nll_if_none()
: Returns NULL
if no named ...
argument is scalar TRUE
. Otherwise, returns a message composed of unnamed ...
args collapsed into a character scalar using the delimiter .d
.
Other forks:
case()
,
swap_help()
fork(c(TRUE, FALSE, TRUE, NA), 1, 2)
fork(c(TRUE, FALSE, TRUE, NA), 1, 2, na = 0)
fork(c(TRUE, FALSE, TRUE, NA), 1, 2, na = NA)
fork(c(TRUE, FALSE, TRUE, NA), 1:4, 5:8)
f0(NA, data.frame(letters = letters), 0:26)
f0(TRUE, data.frame(letters = letters), 0:26)
f0(FALSE, data.frame(letters = letters), 0:26)
f0(list(1, "a"), data.frame(letters = letters), 0:26)
f0(c(.bad.varname.), data.frame(letters = letters), 0:26)
f1(NA, data.frame(letters = letters), 0:26)
f1(NA, data.frame(letters = letters), 0:26, na = NA)
f1(TRUE, data.frame(letters = letters), 0:26)
f1(FALSE, data.frame(letters = letters), 0:26)
f1(list(1, "a"), data.frame(letters = letters), 0:26)
f1(list(1, "a"), data.frame(letters = letters), 0:26)
f1(c(.bad.varname.), data.frame(letters = letters), 0:26)
f1(list(1, "a"), data.frame(letters = letters), 0:26, err = "error")
f1(c(.bad.varname.), data.frame(letters = letters), 0:26, err = "error")
nll_if(TRUE, "an error", "message")
nll_if(FALSE, "an error", "message")
nll_if(41, "an error", "message")
nll_ifs(t1 = TRUE, t2 = FALSE, t3 = FALSE, "not", "any", .cond = "all")
nll_ifs(t1 = TRUE, t2 = FALSE, t3 = FALSE, "not", "all", .cond = "any")
nll_ifs(t1 = TRUE, t2 = FALSE, t3 = FALSE, "not", "none", .cond = "none")
nll_if_any(t1 = TRUE, t2 = FALSE, t3 = FALSE, "not", "any")
nll_if_all(t1 = TRUE, t2 = FALSE, t3 = FALSE, "not", "all")
nll_if_none(t1 = TRUE, t2 = FALSE, t3 = FALSE, "not", "none")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.