to_dictionary: Create Dictionary from Unique Strings

Description Usage Arguments Examples

View source: R/compress_paths.R

Description

Create Dictionary from Unique Strings

Usage

1
to_dictionary(x, prefix = "a", leading_zeros = FALSE)

Arguments

x

vector of strings

prefix

prefix to be given to the keys in the dictionary. Default: "a"

leading_zeros

whether to make all keys in the dictionary have same length by adding leading zeros to the keys. Default: FALSE

Examples

1
2
3
4
5
6
7
8
# Define input strings
x <- c("elephant", "mouse", "cat", "cat", "cat", "mouse", "cat", "cat")

# Create a dictionary for the unique values in x
kwb.pathdict:::to_dictionary(x)

# Note that "cat" is the first entry because it has the highest "importance"
kwb.pathdict:::sorted_importance(x)

KWB-R/kwb.pathdict documentation built on Jan. 13, 2020, 2:24 a.m.