| count_ngrams | R Documentation |
Count contiguous n-grams from a segmented character vector or from each element of a list of segmented character vectors.
count_ngrams(
x,
...,
n = 2,
sep = " ",
sort = TRUE,
format = c("data.frame", "vector")
)
x |
A character vector of tokens or a list of character vectors. |
... |
Must be empty. This enforces that optional arguments such as |
n |
A positive integer or integer vector giving the n-gram sizes to
count. The default is |
sep |
Separator inserted between tokens when constructing the n-gram
label. The default is |
sort |
Whether to sort results by descending frequency. The default
is |
format |
Output format. |
Use n to select one or more n-gram sizes, and sep to control how tokens
are joined in the returned term labels.
N-gram counts in the requested format.
count_ngrams(c("\u6211", "\u7231", "R"), n = 2)
count_ngrams(c("\u6211", "\u7231", "R"), n = 1:2, format = "data.frame")
count_ngrams(c("a", "b", "b", "b", "a"), n = 1, sort = FALSE)
count_ngrams(list(c("a", "b", "c"), c("a", "b")), n = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.