我想让我的R闪亮应用程序显示wordcloud和文本框作为输出 以下是进程运行的两个输入数据框
d<- word frequency
A 12
with 11
offers 10
for 8
DF4< - word frequency
A 12
with 11
offers 10
for 8
我已经设置了一个带有文本输入邮件主题的UI。这链接到动作按钮单击我。在此输入的主题被送入服务器并进行处理以创建输出。
ui<- fluidPage(
textInput("e-mailSubject", label = "SubjectLine",placeholder =
"'"),actionButton("do", "Click Me"),
numericInput("Audience Size", label = "Target Audience Size", value =
c(10000000)),
dateInput("Date",label = "Date of Campaign"),
mainPanel(plotOutput("Plot1"), textOutput("Output1")))
应显示Output1。但事实并非如此。我没有收到任何错误消息。 wordcloud正在显示。
server<-function(input, output, session) {
output$Plot1 <- renderPlot({
set.seed(1234)
wordcloud(words = d$word, freq = d$freq, min.freq = 1,
max.words=200, random.order=FALSE, rot.per=0.35,
colors=brewer.pal(8, "Dark2")) })
output<-renderText(text2<-reactive({input$e-mailSubject
mycorpus2<-Corpus(VectorSource(text2))
mycorpus2<-tm_map(mycorpus2, tolower)
mycorpus2<-tm_map(mycorpus2, removeNumbers)
mycorpus2<-tm_map(mycorpus2, removeWords, c(stopwords("english")))
#Encoding(text) <- "UTF-8"
dtm2<-TermDocumentMatrix(mycorpus2)
m2<-as.matrix(dtm2)
v2 <- sort(rowSums(m2),decreasing=TRUE)
d2 <- data.frame(word = names(v2),freq=v2)
outputtable<-DF4[DF4$variable%in%d2$word,]
outputresult<-sum(outputtable$sum.estimate.)
return(outputresult)
}))
}
shinyApp(ui, server)
我请求别人帮忙。