Q:

Error: No tidy method for objects of class LDA_VEM§

I am literally following the steps as presented in chapter 6 of the "Text Mining in R: a Tidy Approach" book. See: https://www.tidytextmining.com/topicmodeling.html
#import libraries
library(topicmodels)
library(tidytext)

#access dataset
data("AssociatedPress")

# set a seed so that the output of the model is predictable
ap_lda <- LDA(AssociatedPress, k = 2, control = list(seed = 1234))

#tidy model object
ap_topics <- tidy(ap_lda, matrix = "beta")

Gives me the following error in the terminal:
Error: No tidy method for objects of class LDA_VEM

What I should be getting, meanwhile is:
## # A tibble: 20,946 x 3
##    topic term           beta
##    <int> <chr>         <dbl>
##  1     1 aaron      1.69e-12
##  2     2 aaron      3.90e- 5
##  3     1 abandon    2.65e- 5
##  4     2 abandon    3.99e- 5
##  5     1 abandoned  1.39e- 4
##  6     2 abandoned  5.88e- 5
##  7     1 abandoning 2.45e-33
##  8     2 abandoning 2.34e- 5
##  9     1 abbott     2.13e- 6
## 10     2 abbott     2.97e- 5
## # ... with 20,936 more rows

Why am I seeing this error instead of the desired result?

A:

You are not the first person to run into this problem, but it is very difficult to reproduce. In fact, I personally have never been able to reproduce the error. However, I know it is a real problem because, well... If you'd like to see other people also struggling, check out here or here or here or here.
As best as I can tell, this is likely a bug in the topicmodels package, related to S4 registration. You can avoid running into this by not saving .RData between sessions and always starting from a fresh R session when you open up work.

