Sync (expand or compress) a vector
sync_vector( x, newLength, sep = " ", fill = TRUE, compressFun = NULL, expandFun = NULL, compressFunPart = NULL, silent = rock::opts$get("silent") )
The new length
When not specifying
paste function is used to combine elements, and in that case,
paste as separator.
When expanding streams, whether to duplicate elements to fill
the resulting vector. Ignored if
fillFun is specified.
If specified, when compressing streams, instead of pasting
elements together using separator
sep, the vectors are passed to function
compressFun, which must accept a vector (to compress) and a single integer
(with the desired resulting length of the vector).
If specified, when expanding streams, instead of potentially
filling the new larger vector with elements (if
vectors are passed to function
expandFun, which must accept a vector (to
compress) and a single integer (with the desired resulting length of
A function to apply to the segments that are
automatically created; this can be passed instead of
Whether to be silent or chatty.
The synced vector
rock::sync_vector(letters[1:10], 15); #>  "a" "a" "b" "c" "c" "d" "e" "e" "f" "g" "g" "h" "i" "i" "j" rock::sync_vector(letters[1:10], 5); #>  "a b" "c d" "e f" "g h" "i j"