Я пытаюсь построить график с помощью qplot, но получаю сообщение об ошибке: stat_bin () не должен использоваться с эстетическим - PullRequest
0 голосов
/ 01 мая 2019

Используя LDA, я пытаюсь сделать тему моделирования. Для визуализации тем в каждом документе Я пытался использовать qplot, но получаю сообщение об ошибке и предупреждение.

Ошибка: stat_bin () нельзя использовать с эстетикой y. Предупреждающее сообщение: stat устарело

Программа использует набор данных cora.

Это выходной график, который я ищу.

Ниже приведен фрагмент кода:

require("ggplot2")
require("reshape2")
require("lda")
# load documents and vocabulary
data(cora.documents)
data(cora.vocab)
theme_set(theme_bw())
# Number of topic clusters to display
K <- 10
# Number of documents to display
N <- 9
result <- lda.collapsed.gibbs.sampler(cora.documents,
                                      K, ## Num clusters
                                      cora.vocab,
                                      25, ## Num iterations
                                      0.1,
                                      0.1,
                                      compute.log.likelihood=TRUE)
# Get the top words in the cluster
top.words <- top.topic.words(result$topics, 5, by.score=TRUE)
# build topic proportions
topic.props <- t(result$document_sums) / colSums(result$document_sums)
document.samples <- sample(1:dim(topic.props)[1], N)
topic.props <- topic.props[document.samples,]
topic.props[is.na(topic.props)] <- 1 / K
colnames(topic.props) <- apply(top.words, 2, paste, collapse=" ")
topic.props.df <- melt(cbind(data.frame(topic.props),
                             document=factor(1:N)),
                       variable.name="topic",
                       id.vars = "document")

qplot(topic, value*100, fill=topic, stat = "identity",
      ylab="proportion (%)", data=topic.props.df,
      geom="histogram") +
  theme(axis.text.x = element_text(angle=0, hjust=1, size=12)) +
  coord_flip() +
  facet_wrap(~ document, ncol=3)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...