Learn R Programming

textshape (version 1.7.5)

unique_pairs: Extract Only Unique Pairs of Collocating Words in tidy_colo_dtm

Description

tidy_colo_dtm utilizes the entire matrix to generate the tidied data.frame. This means that the upper and lower triangles are used redundantly. This function eliminates this redundancy by dropping one set of the pairs from a tidied data.frame.

Usage

unique_pairs(x, col1 = "term_1", col2 = "term_2", ...)

# S3 method for default unique_pairs(x, col1 = "term_1", col2 = "term_2", ...)

# S3 method for data.table unique_pairs(x, col1 = "term_1", col2 = "term_2", ...)

Value

Returns a filtered data.frame.

Arguments

x

A data.frame with two columns that contain redundant pairs.

col1

A string naming column 1.

col2

A string naming column 2.

...

ignored.

See Also

tidy_colo_dtm

Examples

Run this code
dat <- data.frame(
    term_1 = LETTERS[1:10],
    term_2 = LETTERS[10:1],
    stringsAsFactors = FALSE
)

unique_pairs(dat)

Run the code above in your browser using DataLab