Blow up single scalars / objects to vectors / list by replication
Source:R/ensureVector.R
ensureVector.RdUseful 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.
Arguments
- x
[any]
Input element.- n
[
integer(1)]
Desired length. Default is 1 (the most common case).- cl
[
character*]
Only do the operation ifxinherits from this one of these classes, otherwise simply letxpass. Default isNULLwhich means to always do the operation.- names
[
character*]
Names for result. Default isNULL, which means no names.- ensure.list
[
logical(1)]
Shouldxbe wrapped in a list in any case? Default isFALSE, i.e., ifxis a scalar value, a vector is returned.