ユーザーが検索用語を入力すると、その用語を含むツイートが返される、shiny を使用した Web アプリの作成を開始しました。
このアプリをロードすると、searchTwitter
機能が自動的に開始され、メイン パネルに次のエラーが表示されます。Error: You must enter a query.
検索語は textInput ボックスに入力され、submitButton があります。用語を入力すると問題なく動作しますが、エラーがユーザーに最初に表示されることは望ましくありません。
ui.R:
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Twitter Generator"),
sidebarPanel(
textInput("search", "Search Twitter For:", value = ""),
submitButton("Search")
),
mainPanel(
h3(textOutput("search")),
tableOutput("view"),
)
))
サーバー.R:
library(shiny)
library(twitteR)
shinyServer(function(input, output) {
datasetInput <- reactive(function(){
rawTweets <- twListToDF(searchTwitter(paste(input$search)))
rawTweets$cleanText <- as.vector(sapply(rawTweets$text, CleanTweet))
rawTweets[, colnames(rawTweets) != "created"]
})
output$search <- reactiveText(function() {
input$search
})
output$view <- reactiveTable(function() {
head(datasetInput())
})
})
ご協力いただきありがとうございます