为什么我在1中收到错误:nrow(计数):长度为0的参数

问题描述 投票:0回答:1

我正在使用R中的topicmodels包进行主题建模。我正在创建一个Corpus对象,进行一些基本的预处理,然后创建一个DocumentTermMatrix:

library(topicmodels)

#Set parameters for Gibbs sampling
burnin <- 4000
iter <- 2000
thin <- 500
seed <-list(2003,5,63,100001,765)
nstart <- 5
best <- TRUE

#Number of topics
k <- 8

#Run LDA using Gibbs sampling
# Start the clock!
ptm <- proc.time()
ldaOut <-LDA(dtm.new,k, method="Gibbs", control=list(nstart=nstart, seed = seed, best=best, 
                                                  burnin = burnin, iter = iter, thin=thin))
# Stop the clock
proc.time() - ptm

然后我在最后一行得到了错误

 #docs to topics

ldaOut.topics <- as.matrix(topics(ldaOut))

这是错误:

error in 1:nrow(counts) : argument of length 0

我认为这意味着它不能计算第一行。有没有办法检查。

r lda topic-modeling topicmodels
1个回答
0
投票

topic()还没有给你一个矩阵吗?

在任何情况下,“长度为零的参数”告诉您对象“计数”具有零行。

© www.soinside.com 2019 - 2024. All rights reserved.