unique_pairs {textshape}R Documentation

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

## Default S3 method:
unique_pairs(x, col1 = "term_1", col2 = "term_2", ...)

## S3 method for class '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

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

unique_pairs(dat)

[Package textshape version 1.7.5 Index]