Expand a vector or data frame

syncing_df_expand(
  x,
  newLength,
  fill = TRUE,
  expandFun = NULL,
  silent = rock::opts$get("silent")
)

syncing_vector_expand(
  x,
  newLength,
  fill = TRUE,
  expandFun = NULL,
  silent = rock::opts$get("silent")
)

Arguments

x

The vector or data frame

newLength

The new length (or number of rows for a data frame)

fill

When expanding streams, whether to duplicate elements to fill the resulting vector. Ignored if fillFun is specified.

expandFun

If specified, when expanding streams, instead of potentially filling the new larger vector with elements (if fill is TRUE), the vectors are passed to function expandFun, which must accept a vector (to compress) and a single integer (with the desired resulting length of the vector).

silent

Whether to be silent or chatty.

Value

The expanded vector

Examples

rock::syncing_vector_expand(letters[1:10], 15);
#>  [1] "a" "b" "b" "c" "d" "d" "e" "f" "f" "g" "h" "h" "i" "j" "j"
rock::syncing_vector_expand(letters[1:10], 15, fill=FALSE);
#>  [1] "a" "b" ""  "c" "d" ""  "e" "f" ""  "g" "h" ""  "i" "j" ""