pad0 {LifeInsureR}R Documentation

Pad a vector with 0 to a desired length

Description

Pad a vector with 0 to a desired length

Usage

pad0(v, l, value = 0, start = 0, value.start = 0)

Arguments

v

the vector to pad with 0

l

the desired (resulting) length of the vector

value

the value to pad with (if padding is needed). Default to 0, but can be overridden to pad with any other value.

start

the first start values are always set to 0 (default is 0, can be changed using the value.start argument), the vector v starts only after these leading zeroes. The number of leading zeroes counts towards the desired length

value.start

the value to insert before the start index.

Value

returns the vector v padded to length l with value value (default 0).

Examples

pad0(1:5, 7)   # Pad to length 7 with zeroes
pad0(1:5, 3)   # no padding, but cut at length 3

# 3 leading zeroes, then the vector start (10 elements of vector, no additional padding needed):
pad0(1:10, 13, start = 3)

# padding with value other than zero:
pad0(1:5, 7, value = "pad")

[Package LifeInsureR version 1.0.0 Index]