partial_unique: Construct partially unique string list

Description Usage Arguments Details Value See Also Examples

Description

partial_unique makes given characters as short as posssible while preserving uniqueness.

Usage

1
partial_unique(originalv = c("mpg", "cyl", "disp", "hp", "drat"), i = 1)

Arguments

originalv

a character vector to construct partial strings.

i

The smallest character of the resulted partial strings. Sometimes too small i loses readability such as in show_dataset_column_indices

Details

partial_unique is a variant of R's builtin unique function. While link[base]{unique} returns the non-duplicated set of elements, partial_unique returns a list whose element names are partially unique shortest strings, and its element values are original strings. This function can display how many characters are needed to uniquely identify each given character element.

Value

a list whose element names are partial strings and element values are original strings.

See Also

unique, show_dataset_column_indices

Examples

1
2
3
partial_unique(c("Sepal.Width", "Sepal.Length", "Species", "Petal.Width"))
# returns list(Sepal.W = "Sepal.Width", Sepal.L = "Sepal.Length",
#              Sp = "Species", P = "Petal.Width")

caprice-j/ggbash documentation built on May 13, 2019, 12:11 p.m.