Plots terms preceding/proceeding a chosen term to give more context around how it is used in conversation.
Arguments
- df
A dataframe.
- text_var
The variable containing text.
- term
The chosen term in lowercase.
- preceding_n
An integer representing the number of terms to precede the chosen term.
- proceeding_n
An integer representing the number of terms to proceed the chosen term.
- top_n
The maximum number of ngrams to display, filtered by ngram count.
Examples
{
term_context(sprinklr_export, Message, "trump", preceding_n = 2, proceeding_n = 2, top_n= 5)
}
#> $plot
#>
#> $frequencies
#> # A tibble: 7 × 6
#> `x-2` `x-1` x `x+1` `x+2` n
#> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 supported donald trump while 22 3
#> 2 32 supported trump while only 2
#> 3 beat donald trump among the 2
#> 4 president donald trump 83 84 2
#> 5 students favoring trump by a 2
#> 6 understand why trump being the 2
#> 7 vote donald trump receiving 41 2
#>