当我尝试在Shiny app中绘制wordcloud时出现此错误
"Warning in max(freq) : no non-missing arguments to max; returning -Inf
Warning: Error in strwidth: invalid 'cex' value"
这是我的代码,这段代码在server.R
中library(shiny)
library(quanteda)
library(wordcloud)
require(readtext)
source('helperScript.R')
shinyServer(function(input, output) {
output$prediction <- renderTable({
result <- predicted()
if(! is.null(result))
p<- predicted()[,1]
})
output$plot <- renderPlot({
result <- predicted()
wordcloud_rep <- repeatable(wordcloud)
d <- data.frame(word = result[,1],freq= result[,2])
wordcloud_rep(words= d$word,freq =d$freq, scale=c(4,0.5),
min.freq =1, max.words=50,
colors=brewer.pal(8, "Dark2"))
})
predicted <- eventReactive(
#execute with button "Go" clicked, nothing else
input$go, {
#Get Input from the UI
inputTxt <- input$inputTxt
words <- processInput(inputTxt)
word1 <- words[1,]
word2 <- words[2,]
withProgress({
setProgress(message = "Processing corpus...")
predictNextWord(word1, word2)
})
})
})