
#install.packages('topicmodels', repos = "http://cran.us.r-project.org")
library(topicmodels)

data("AssociatedPress")
# specify a seed value so the model output is predictable
ap_lda <- LDA(AssociatedPress, k = 2, control = list(seed = 1234))
ap_lda

library(tidytext)
paste0("Word-topic probabilities:",collapse=" ")
ap_topics <- tidy(ap_lda, matrix = "beta")
ap_topics


