我有一个数据帧-DF4用于术语和回归系数
DF4
variable sum.estimate.
A 0.7685268935
with 0.2454782079
offers 0.0586034657
for 0.0563342240
you 0.1297090046
exclusive 0.1357726776
offer 0.1922095907
gift -0.0100579666
pay 0.1733257543
以上是作为R中的数据框导入的。接下来我们创建一个闪亮的仪表板
if (interactive()){
ui<- fluidPage(textInput("e-mailSubject",
label = "SubjectLine",
placeholder = "'"),actionButton("do", "Click Me"),
mainPanel(textOutput(outputId = "CTR",
container = "SPAMSCORE",inline = "Left" ),
plotOutput("Plot1")))
服务器有输入。输入是textInput中的文本。主题行被转换为术语文档矩阵,然后我们使用查找来获得输出值 - 可输出。
server<-function(input, output, session, DF4) {
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")) })
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,]
return(output)
})
output$Output1=renderPrint({sum(outputtable$estimatesum)})
}
shinyApp(ui, server)
我已经更正了代码,现在出现了wordcloud。我的文本输出中出现错误 错误:找不到对象'outputtable'
我被困在这部分几个小时。我请求别人看一看并指导我。