compressing_vectors_or_dataframes: Compress a vector or data frame

syncing_df_compressR Documentation

Compress a vector or data frame

Description

Compress a vector or data frame

Usage

syncing_df_compress(
  x,
  newLength,
  sep = " ",
  compressFun = NULL,
  compressFunPart = NULL,
  silent = rock::opts$get("silent")
)

syncing_vector_compress(
  x,
  newLength,
  sep = " ",
  compressFun = NULL,
  compressFunPart = 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)

sep

When not specifying compressFun and compressFunPart, the paste function is used to combine elements, and in that case, sep is passed to paste as separator.

compressFun

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).

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.

Value

The compressed vector or data frame

Examples

rock::syncing_vector_compress(
  1:10,
  3
);

rock::syncing_df_compress(
  mtcars[, 1:4],
  6
);

rock::syncing_df_compress(
  mtcars[, 1:4],
  6,
  compressFunPart = mean
);

rock documentation built on Dec. 28, 2022, 1:55 a.m.