R/get_td_gamma.R

Defines functions get_td_gamma

Documented in get_td_gamma

#' @title get the gamma matrix from an stm topic model object
#' @description get a broom::tidy matrix containing the probabiliies each document is generated from each topic
#' @usage 
#' get_td_gamma(topicModel)
#' @param topicModel the stm topic model from which to extract the beta matrix
#' @return a tbl_df with columns "document", "topic", "gamma"
#' @importFrom tidytext tidy
#' @examples 
#' \dontrun{
#' data("tm_ex_dat")
#' 
#' get_td_gamma(tm_ex_dat$topic_model_test)
#' }
#' @export
get_td_gamma <- function(topicModel) {
  topicModel %>% 
    tidy(matrix = "gamma")
}
tknoch8/topicHelpers documentation built on Nov. 11, 2023, 1:15 a.m.