R: Blow up single scalars / objects to vectors / list by...

ensureVector {BBmisc} | R Documentation

## Blow up single scalars / objects to vectors / list by replication.

### Description

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.

### Usage

    ensureVector(x, n = 1L, cl = NULL, names = NULL, ensure.list = FALSE)

### Arguments

`x` | [any] Input element.
`n` | [`integer(1)`] Desired length. Default is 1 (the most common case).
`cl` | [`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.
`names` | [`character`*] Names for result. Default is `NULL`, which means no names.
`ensure.list` | [`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.

### Value

Ether a vector or list of length `n` with replicated `x` or `x` unchanged..

[Package BBmisc version 1.11 Index]