Learn R Programming

surveillance (version 1.24.0)

clapply: Conditional lapply

Description

Use lapply if the input is a list and otherwise apply the function directly to the input and wrap the result in a list. The function is implemented as


    if (is.list(X)) lapply(X, FUN, ...) else list(FUN(X, ...))

Usage

clapply(X, FUN, ...)

Value

a list (of length 1 if X is not a list).

Arguments

X

a list or a single R object on which to apply FUN.

FUN

the function to be applied to (each element of) X.

...

optional arguments to FUN.