Useful for standard argument conversion where a user can input a single element, but this has to be replicated now n times for a resulting vector or list.
ensureVector(x, n = 1L, cl = NULL, names = NULL, ensure.list = FALSE)
Ether a vector or list of length n
with replicated x
or x
unchanged..
[any]
Input element.
[integer(1)
]
Desired length.
Default is 1 (the most common case).
[character
*]
Only do the operation if x
inherits from this one of these classes,
otherwise simply let x
pass.
Default is NULL
which means to always do the operation.
[character
*]
Names for result.
Default is NULL
, which means no names.
[logical(1)
]
Should x
be wrapped in a list in any case?
Default is FALSE
, i.e., if x
is a scalar value, a vector is
returned.