matchLengths | R Documentation |
Internal soundgen function.
matchLengths(
myseq,
len,
padDir = c("left", "right", "central")[3],
padWith = 0
)
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 |
Adjusts a vector to match the required length by either trimming one or both ends or padding them with zeros.
Returns the modified vector of the required length.
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 = 10, padDir = 'left')
#' # trimmed on the right
soundgen:::matchLengths(3:7, len = 3, padDir = 'right')
# padded with zeros on the right
soundgen:::matchLengths(3:7, len = 10, padDir = 'right')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.