squeeze {bggAnalytics}R Documentation

Squeeze integers into a single string

Description

This acts similar to toString function, but it tries to make the string as short as possible by squeezing sequences of integers into boundary values only. Please see the examples section. unsqueez reverses this operation.

Usage

squeeze(integers)

unsqueeze(strings, strict = FALSE)

Arguments

integers

a numeric vector of integers.

strings

a character vector of strings, preferably outputs of squeeze.

strict

a logical value, decides whether the output should be strictly a list. If FALSE and the strings is a single string, the function returns an atomic vector instead.

Value

squeeze returns a vector of characters, unsqueeze returns a list of numerics or a numeric vector.

Author(s)

Jakub Bujnowicz bujnowiczgithub@gmail.com

Examples

integers <- c(1, 3:5, NA, 27:38, 10:13, 9:11, 6)
squeeze(integers)

unsqueeze(squeeze(integers))
setdiff(na.omit(integers), unsqueeze(squeeze(integers)))


[Package bggAnalytics version 0.2.1 Index]