Learn R Programming

stringdist (version 0.5.0)

qgrams: Get a table of qgram counts from a character vector.

Description

Get a table of qgram counts from a character vector.

Usage

qgrams(x, q)

Arguments

x
character vector
q
size of q-gram, must be non-negative.

Value

  • An object of class table

Details

The input is converted to character. Each element is converted to integer via utf8 as in stringdist, prior to passing the data to the underlying routine. The names of the output table (i.e. the qgrams) are encoded in utf8.

See Also

stringdist.

Examples

Run this code
qgrams('hello world',q=3)

# q-grams are counted uniquely over a character vector
qgrams(rep('hello world',2),q=3)

# to count them separately, do something like
x <- c('hello', 'world')
lapply(x,qgrams, q=3)

Run the code above in your browser using DataLab