textshape (version 1.6.0)

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", ...)

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.

Value

Returns a filtered data.frame.

See Also

tidy_colo_dtm

Examples

Run this code
# NOT RUN {
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