Sync (expand or compress) a vector
Usage
sync_vector(
x,
newLength,
sep = " ",
fill = TRUE,
compressFun = NULL,
expandFun = NULL,
compressFunPart = NULL,
silent = rock::opts$get("silent")
)Arguments
- x
The vector
- newLength
The new length
- sep
When not specifying
compressFunandcompressFunPart, thepastefunction is used to combine elements, and in that case,sepis passed topasteas separator.- fill
When expanding streams, whether to duplicate elements to fill the resulting vector. Ignored if
fillFunis specified.- compressFun
If specified, when compressing streams, instead of pasting elements together using separator
sep, the vectors are passed to functioncompressFun, which must accept a vector (to compress) and a single integer (with the desired resulting length of the vector).- expandFun
If specified, when expanding streams, instead of potentially filling the new larger vector with elements (if
fillisTRUE), the vectors are passed to functionexpandFun, which must accept a vector (to compress) and a single integer (with the desired resulting length of the vector).- compressFunPart
A function to apply to the segments that are automatically created; this can be passed instead of
compressFun.- silent
Whether to be silent or chatty.
