cosine_distance: Optimized Computation of Cosine Distance

Description Usage Arguments Value Author(s) References Examples

Description

Utilizes the slam package to efficiently calculate cosine distance on large sparse matrices.

Usage

1
2
3
4
5
6
7
cosine_distance(x, ...)

## S3 method for class 'DocumentTermMatrix'
cosine_distance(x, ...)

## S3 method for class 'TermDocumentMatrix'
cosine_distance(x, ...)

Arguments

x

A data type (e.g., DocumentTermMatrix or TermDocumentMatrix).

...

ignored.

Value

Returns a cosine distance object of class "dist".

Author(s)

Michael Andrec and Tyler Rinker <tyler.rinker@gmail.com>.

References

http://stackoverflow.com/a/29755756/1000343

Examples

1
2
3
4
5
6
library(gofastr)
library(dplyr)

out <- presidential_debates_2012 %>%
    with(q_dtm(dialogue)) %>%
    cosine_distance()

trinker/clustext documentation built on May 31, 2019, 8:41 p.m.