Learn R Programming

rock (version 0.8.1)

syncing_df_compress: 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") )

Value

The compressed vector or data frame

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.

Examples

Run this code
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
);

Run the code above in your browser using DataLab