search_term_collocations: Search For Collocations

Description Usage Arguments Value Author(s) Examples

View source: R/search_term_collocations.R

Description

A wrapper for search_term + frequent_terms. Find words that frequently collocate with a term(s). Note that the 'term regexes are eliminated from the output of top occurring terms.

Usage

1
search_term_collocations(text.var, term, n = 10, ignore.case = TRUE, ...)

Arguments

text.var

A vector of character strings.

term

A regular expression(s) to search for (uses grep).

n

The number of rows to print. If integer selects the frequency at the nth row and prints all rows >= that value. If proportional (less than 0) the frequency value for the nth% row is selected and prints all rows >= that value.

ignore.case

logical. Should grep be done independent of case?

...

Other arguments passed to search_term and frequent_terms.

Value

Returns a data.frame of collocating terms and frequencies.

Author(s)

Steve T. Simpson and Tyler Rinker <tyler.rinker@gmail.com>.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## Example 1
search_term_collocations(sam_i_am, "\\bsam")
search_term_collocations(sam_i_am, c('green', "\\bsam"))
search_term_collocations(sam_i_am, c('green', "\\bsam"), min.char=2)

## Example 2
top_colo <- search_term_collocations(
    presidential_debates_2012[["dialogue"]],
    "president",
    n =50
)

top_colo
plot(top_colo)
plot(top_colo, as.cloud=TRUE)

## Example 3
top_colo_exclude <- search_term_collocations(
    presidential_debates_2012[["dialogue"]],
    "president",
    exclude = "obama",
    n =50
)

top_colo_exclude
plot(top_colo_exclude)

trinker/termco documentation built on Jan. 7, 2022, 3:32 a.m.