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, ...))
clapply(X, FUN, ...)

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.

Value

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