compression_helper_functions: Vector compression helper functions

compress_with_sumR Documentation

Vector compression helper functions

Description

These functions can help when compressing vectors. They always compress their input (x) into a single element by various means.

Usage

compress_with_sum(x)

compress_with_or(x)

Arguments

x

The vector to compress

Details

compress_with_sum computes the sum of the elements, doing its best to convert all input values to numeric values. compress_with_or returns 0 if all elements are FALSE, 0, NA or empty character values (""), and 1 otherwise.

Value

The compressed element

Examples

rock::compress_with_sum(c(1, '1', 0));
rock::compress_with_or(c(1, '1', 0));
rock::compress_with_or(c(0, '', 0, FALSE));

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