ngrams | R Documentation |
Compute the n
-grams (contiguous sub-sequences of length n
)
of a given sequence.
x |
a sequence (vector). |
n |
a positive integer giving the length of contiguous sub-sequences to be computed. |
a list with the computed sub-sequences.
s <- "The quick brown fox jumps over the lazy dog"
## Split into words:
w <- strsplit(s, " ", fixed = TRUE)[[1L]]
## Word tri-grams:
ngrams(w, 3L)
## Word tri-grams pasted together:
vapply(ngrams(w, 3L), paste, "", collapse = " ")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.