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, cl = NULL, names = NULL)

Arguments

x

[any]
Input element.

n

[integer]
Desired length.

cl

[character(1)*]
Only do the operation if x inherits from this class, 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.

Value

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


[Package BBmisc version 1.7 Index]