Skip to content

Instantly share code, notes, and snippets.

View a-paxton's full-sized avatar

Alexandra Paxton a-paxton

View GitHub Profile
@a-paxton
a-paxton / topicmodels_json_ldavis.R
Last active November 15, 2015 08:43 — forked from christophergandrud/topicmodels_json_ldavis.R
Convert the output of a topicmodels Latent Dirichlet Allocation model to JSON for use with LDAvis
#' Convert the output of a topicmodels Latent Dirichlet Allocation to JSON
#' for use with LDAvis
#'
#' @param fitted Output from a topicmodels \code{LDA} model.
#' @param corpus Corpus object used to create the document term
#' matrix for the \code{LDA} model. This should have been create with
#' the tm package's \code{Corpus} function.
#' @param doc_term The document term matrix used in the \code{LDA}
#' model. This should have been created with the tm package's
#' \code{DocumentTermMatrix} function.