0

When I apply the tidy function to the result of the LDA model in my dataset, I get the following error "Error in eval(substitute(expr), envir, enclos) : binding not found: 'Var1'". I get the same error when used on associated press example, as shown below. I tried reinstalling the tidytext via devtools::install_github("juliasilge/tidytext") and I still get the same result. Is there something else I can try?

library(tidyr) library(tidytext) library(tidyverse) library(topicmodels) library(Broom)

data("AssociatedPress") AssociatedPress

ap_lda <- LDA(AssociatedPress, k = 2, control = list(seed = 1234)) ap_lda

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

<> Non-/sparse entries: 302031/23220327 Sparsity : 99% Maximal term length: 18 Weighting : term frequency (tf)

ap_lda <- LDA(AssociatedPress, k = 2, control = list(seed = 1234)) ap_lda A LDA_VEM topic model with 2 topics.

ap_topics <- tidy(ap_lda, matrix = "beta") Error in eval(substitute(expr), envir, enclos) : binding not found: 'Var1' ap_topics

1 Answers1

1

I cannot reproduce this problem.

library(tidyverse)
library(tidytext)
library(broom)
library(topicmodels)

data("AssociatedPress", package = "topicmodels") 
AssociatedPress
#> <<DocumentTermMatrix (documents: 2246, terms: 10473)>>
#> Non-/sparse entries: 302031/23220327
#> Sparsity           : 99%
#> Maximal term length: 18
#> Weighting          : term frequency (tf)

ap_lda <- LDA(AssociatedPress, k = 2, control = list(seed = 1234)) 
ap_lda
#> A LDA_VEM topic model with 2 topics.

ap_topics <- tidy(ap_lda, matrix = "beta") 
ap_topics
#> # A tibble: 20,946 x 3
#>    topic       term         beta
#>    <int>      <chr>        <dbl>
#>  1     1      aaron 1.686917e-12
#>  2     2      aaron 3.895941e-05
#>  3     1    abandon 2.654910e-05
#>  4     2    abandon 3.990786e-05
#>  5     1  abandoned 1.390663e-04
#>  6     2  abandoned 5.876946e-05
#>  7     1 abandoning 2.454843e-33
#>  8     2 abandoning 2.337565e-05
#>  9     1     abbott 2.130484e-06
#> 10     2     abbott 2.968045e-05
#> # ... with 20,936 more rows

Do you have another package loaded, maybe? Another user had a problem with the reshape package.

Julia Silge
  • 10,848
  • 2
  • 40
  • 48
  • I faced the same problem with lda_tidier and reshape seemed to be the issue. Is there any fix for this other than not loading the library reshape? – ar7 Sep 07 '17 at 13:27
  • Not at this time; it's related to some internals to both packages. This may be something you already know how to do, but for the record, instead of loading both packages, you can just access the function using `::`. So do NOT type `library(reshape)` but call the functions like `reshape::melt()`. – Julia Silge Sep 07 '17 at 17:18