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

4

1 回答 1

1

我无法重现此问题。

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

你有没有加载另一个包,也许?另一个用户对reshape包有问题。

于 2017-07-28T02:45:22.390 回答