Generate counts for the most frequent n-grams in text.

count_ngram(
 df,
 text_var = Message,
 n = 2,
 top_n = 50,
 min_freq = 10,
 hashtags = FALSE,
 mentions = FALSE,
 clean_text  = TRUE
)

Arguments

df

A dataframe.

text_var

The variable containing the text.

n

The number of terms to include in the n-gram. E.g. 2 produces a bi-gram.

top_n

The number of n-grams to include.

min_freq

The minimum number of times an n-gram must be observed to be included.

hashtags

Should hashtags be included in the n-grams?

mentions

Should mentions be included in the n-grams?

clean_text

Should the text variable be cleaned?

Value

A list containing a summary table and a tidygraph object suitable for a network visualisation.