matchLengths: Resize vector to required length

Description Usage Arguments Details Value Examples

View source: R/utilities_math.R

Description

Internal soundgen function.

Usage

1
2
matchLengths(myseq, len, padDir = c("left", "right", "central")[3],
  padWith = 0)

Arguments

myseq

input vector

len

target length

padDir

specifies the affected side. For padding, it is the side on which new elements will be added. For trimming, this is the side that will be trimmed. Defaults to 'central'

padWith

if the vector needs to be padded to match the required length, what should it be padded with? Defaults to 0

Details

Adjusts a vector to match the required length by either trimming one or both ends or padding them with zeros.

Value

Returns the modified vector of the required length.

Examples

1
2
3
4
5
6
soundgen:::matchLengths(c(1, 2, 3), len = 5)
soundgen:::matchLengths(3:7, len = 3)
# trimmed on the left
soundgen:::matchLengths(3:7, len = 3, padDir = 'left')
# padded with zeroes on the left
soundgen:::matchLengths(3:7, len = 30, padDir = 'left')

tatters/soundgen_beta documentation built on May 14, 2019, 9 a.m.