Learn R Programming

biogram (version 1.6.3)

count_total: Count total number of n-grams

Description

Computes total number of n-grams that can be extracted from sequences.

Usage

count_total(seq, n, d)

Arguments

seq

a vector or matrix describing sequence(s).

n

integer size of n-gram.

d

integer vector of distances between elements of n-gram (0 means consecutive elements). See Details.

Value

An integer rperesenting the total number of n-grams.

Details

The maximum number of possible n-grams is limited by their length and the distance between elements of the n-gram.

Examples

Run this code
# NOT RUN {
seqs <- matrix(sample(1L:4, 600, replace = TRUE), ncol = 50)
# make several sequences shorter by replacing them partially with NA
seqs[8L:11, 46L:50] <- NA
seqs[1L, 31L:50] <- NA
count_total(seqs, 3, c(1, 0))
# }

Run the code above in your browser using DataLab