Learn R Programming

ggbash (version 0.4.5)

partial_unique: Construct partially unique string list

Description

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

Usage

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

Value

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

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.

See Also

unique, show_dataset_column_indices

Examples

Run this code
# NOT RUN {
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")

# }

Run the code above in your browser using DataLab