【发布时间】:2017-08-14 01:22:54
【问题描述】:
我试图通过单击按钮将文本框中输入的字符串值传递给另一个名为 test.R 的 R 文件
传递的值 ntext 输入到我的测试中的另一个变量。R
Server.R
shinyServer(function(input, output) {
ntext <- eventReactive(input$goButton, {input$text})
output$ntext <- renderText({ntext()
assign('ntext',envir=.GlobalEnv)
})
})
invisible(readline(prompt="Press [enter] to continue")) 来源(“test.R”)
Ui.R
shinyUI(fluidPage(
titlePanel("Sentiment Analysis"),
sidebarLayout(
sidebarPanel(
helpText("See current opinion around the globe " ),
textInput("text", "Keyword"),
actionButton("goButton", "Go!"),
mainPanel(
mainPanel(uiOutput('tweets_txt'))
)
)
))
Test.R
s<-searchTwitter(ntext(),100,lang="en")
df <- do.call("rbind", lapply(s, as.data.frame))
df$text <- sapply(df$text,function(row) iconv(row, "latin1", "ASCII", sub=""))
#tweets_txt<-sapply(df$text,function(x) x$getText())
write.table(df$text,file="C:/Users/mtech/Desktop/Twitter/EXTRACT/SentiT/output.txt")
tweets_txt<-df$text
我根据您的建议编辑了代码,但没有将值传递给 Test.R 也必须仅在用户输入文本框后才传递值,这就是我包含一条不可见的线以暂时停止执行的原因
请推荐
【问题讨论】:
-
您可以在您的应用程序中获取文件
test.R并在该文件中编写一个函数,该函数将ntext作为输入。 -
试过了,但ntext本身不能被识别为R中的变量