tidy_specificities: Returns a tibble with specificities according to two crossed...

View source: R/tidy_specificities.R

tidy_specificitiesR Documentation

Returns a tibble with specificities according to two crossed categories.

Description

Returns a tibble with specificities according to two crossed categories.

Usage

tidy_specificities(mydf, cat1, cat2, top_spec = NA, min_spec = NA)

Arguments

mydf

a tibble

cat1

a factor corresponding to words or lemmas

cat2

a category

top_spec

how many items by category (filter based on specificity) should be kept. If not provided (the default) everything is kept.

min_spec

which is the minimum specificity for an item to be kept. If not provided (the default) everything is kept.

Value

tibble with additional columns cat1, cat2, spec

Examples

 mydf=dplyr::bind_rows(
         tibble::tibble(txt=janeaustenr::prideprejudice,
         novel="Pride and Prejudice"),
         tibble::tibble(txt=janeaustenr::sensesensibility,
         novel="Sense and Sensibility")) %>%
      tidytext::unnest_tokens(word,txt)
 tidy_specificities(mydf,
                    cat1=word,
                    cat2=novel)

lvaudor/mixr documentation built on Feb. 5, 2024, 12:37 a.m.