count_specified: Count specified n-grams

Description Usage Arguments Details Value See Also Examples

View source: R/count_specified.R

Description

Counts specified n-grams in the input sequence(s).

Usage

1

Arguments

seq

vector or matrix describing sequence(s).

ngrams

vector of n-grams.

Details

count_specified counts only selected n-grams declared by user in the ngrams parameter. Declared n-grams must be written using the biogram notation.

Value

A simple_triplet_matrix where columns represent n-grams and rows sequences.

See Also

Count all possible n-grams: count_ngrams.

Examples

1
2
3
4
5
6
7
seqs <- matrix(c(1, 2, 2, 1, 2, 1, 2, 1, 1, 2, 3, 4, 1, 2, 2, 4), nrow = 2)
count_specified(seqs, ngrams = c("1.1.1_0.0", "2.2.2_0.0", "1.1.2_0.0"))

seqs <- matrix(sample(1L:5, 200, replace = TRUE), nrow = 20)
count_specified(seqs, ngrams = c("2_4.2_0", "2_1.4_0", "3_1.3_0",
                                 "2_4.2_1", "2_1.4_1", "3_1.3_1",
                                 "2_4.2_2", "2_1.4_2", "3_1.3_2"))

biogram documentation built on March 31, 2020, 5:14 p.m.