patterns_in_topics: Check occurrence and rank of patterns per topic

View source: R/patterns_in_topics.R

patterns_in_topicsR Documentation

Check occurrence and rank of patterns per topic

Description

Check occurrence and rank of patterns per topic

Usage

patterns_in_topics(term_patterns, topics, check_n_top_terms = 50)

Arguments

term_patterns

The term patterns to be checked for each topic. Passed to grep, hence, regex such as "|" for checking multiple terms at a time allowed.

topics

A character matrix containing term lists per topic. The input might e.g. be topicmodels::terms(model, model@Dim[2])

check_n_top_terms

The number of top terms to be considered for the check.

Value

A list of character matrices named after and having elements equal to number of term_patterns. Matrices contain the input topics reduced to the columns that contain the pattern to be checked and reduced to number of rows as specified via check_n_top_terms. Furthermore, the minimum rank (1 is best) of the pattern in each topic is pasted into the respective colname.

Examples




patterns_in_topics(term_patterns = c("environ*", "terms")
                  , topics = cbind(c("irrelevant", "topic", "terms"), c("global", "environmental", "protection"))
                  , check_n_top_terms = 2)
$`environ*`
Topic 2 - min_rank_2
[1,] "global"
[2,] "environmental"

$terms
NULL

manuelbickel/textility documentation built on Nov. 25, 2022, 9:07 p.m.