Learn R Programming

biogram (version 1.6.3)

position_ngrams: Position n-grams

Description

Tranforms a vector of positioned n-grams into a list of positions filled with n-grams that start on them.

Usage

position_ngrams(ngrams, df = FALSE, unigrams_output = TRUE)

Arguments

ngrams

a vector of positioned n-grams (as created by count_ngrams).

df

logical, if TRUE returns a data frame, if FALSE returns a list.

unigrams_output

logical, if TRUE extracts unigrams from the data and returns information about their position.

Value

if df is FALSE, returns a list of length equal to the number of unique n-gram starts present in n-grams. Each element of the list contains n-grams that start on this position. If df is FALSE, returns a data frame where first column contains n-grams and the second column represent their start positions.

See Also

Transform n-gram name to human-friendly form: decode_ngrams.

Validate n-gram structure: is_ngram.

Examples

Run this code
# NOT RUN {
# position data in the list format
position_ngrams(c("2_1.1.2_0.1", "3_1.1.2_0.0", "3_2.2.2_0.0"))
# position data in the data frame format
position_ngrams(c("2_1.1.2_0.1", "3_1.1.2_0.0", "3_2.2.2_0.0"), df = TRUE)
# }

Run the code above in your browser using DataLab