Internal soundgen function.
matchLengths(myseq, len, padDir = c("left", "right", "central")[3],
padWith = 0)
input vector
target length
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'
if the vector needs to be padded to match the required length, what should it be padded with? Defaults to 0
Returns the modified vector of the required length.
Adjusts a vector to match the required length by either trimming one or both ends or padding them with zeros.
# NOT RUN {
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 zeros on the left
soundgen:::matchLengths(3:7, len = 30, padDir = 'left')
# }
Run the code above in your browser using DataLab