我正在寻找根据潜在Dirichlet分配功能的结果制作三维图的方法。这是我的代码:
library(lda)
example <- c("price house expectations growth positive
scotland report increase demand rise", "price house luxury beautiful mansion
scotland report increase demand rise", "price house maximum growth expected
scotland report increase demand rise")
# converting the data into lda format
corpus <- lexicalize(example, lower=TRUE)
corpus$documents
K=2
num.iterations=100
alpha=0.5
eta=0.5
result = lda.collapsed.gibbs.sampler(corpus$documents, K, corpus$vocab, num.iterations,
alpha,eta, initial = NULL, burnin = NULL,
compute.log.likelihood = FALSE,trace = 0L,
freeze.topics = FALSE)
有人可以帮我提供帮助来制作图表。到目前为止,这是我尝试过的:
library(LDAvis)
createJSON(as.matrix(corpus$phi), integer(corpus$term.frequency),
as.character(corpus$vocab), topic.proportion)
然而,我知道我犯了一个错误,但我不知道在哪里。我得到以下答案:
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
'data' must be of a vector type, was 'NULL'
亲切的问候,