pairwise_pmi | R Documentation |
Find pointwise mutual information of pairs of items in a column, based on a "feature" column that links them together. This is an example of the spread-operate-retidy pattern.
pairwise_pmi(tbl, item, feature, sort = FALSE, ...) pairwise_pmi_(tbl, item, feature, sort = FALSE, ...)
tbl |
Table |
item |
Item to compare; will end up in |
feature |
Column describing the feature that links one item to others |
sort |
Whether to sort in descending order of the pointwise mutual information |
... |
Extra arguments passed on to |
A tbl_df with three columns, item1
, item2
, and
pmi
.
library(dplyr) dat <- tibble(group = rep(1:5, each = 2), letter = c("a", "b", "a", "c", "a", "c", "b", "e", "b", "f")) # how informative is each letter about each other letter pairwise_pmi(dat, letter, group) pairwise_pmi(dat, letter, group, sort = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.