encode: Encode a Vector of Character

View source: R/encode_decode.R

encodeR Documentation

Encode a Vector of Character

Description

Encode a Vector of Character

Usage

encode(x, level = 1, chars = printable_chars(level))

Arguments

x

vector of character

level

one of 1, 2, or 3 defining which character set to use for encoding, see printable_chars.

chars

vector of characters to be used for encoding

Value

vector of character as long as x with each element containing the encoded version of the corresponding element in x. The returned vector has an attribute codes being a named vector. This vector contains the unique values in x as elements. Each element is named by the code that was used to encode the corresponding element.

Examples

x <- c("very-long-word", "very-long-word", "very-very-long-word")
encoded <- encode(x)
encoded
decode(encoded)


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.