Я хочу, чтобы при нажатии на кнопку поиска показывался результат на отдельной странице, а не на этой же странице.Я попробовал два кода первый:
UI:
ui = fluidPage(
theme = shinytheme("cerulean"),
mainPanel(
div(align = "center", style="margin-left:500px",
radioButtons("typeInput", "Extract tweets by: ",list("Hashtag" = "hashtag", "Twitter Username"= "username"),inline=T),
textInput("hashtagInput", "Enter search string","", placeholder = "input search string"),
conditionalPanel(
condition = "input.typeInput == 'username'",
textInput("usernameInput", "Username", placeholder = "input username")),
sliderInput("numberInput", "Select number of tweets",min = 0, max = 3000, value = 100),
br(),
actionButton("goButton", "Search", icon("twitter"),
style="color: #fff; background-color: #337ab7"),
uiOutput("pageStub")
)))
сервер:
server = function(input, output){
data = eventReactive(input$goButton, {
if (input$typeInput == "hashtag") {
tweetOutput = searchThis(search_string = input$hashtagInput,
number.of.tweets = input$numberInput)}
else if (input$typeInput == "username") {
tweetOutput = userTL(user.name = input$usernameInput,number.of.tweets = input$numberInput)}
else {}
library(twitteR)
df.tweets = data.frame(tweetOutput)
tweetOutput = df.tweets})
uiOutput(
output$pageStub <- renderUI(
fluidPage(
fluidRow(
renderDataTable({data()}, options = list(lengthMenu = c(10, 30, 50), pageLength = 5))))))}
, но он показывает результат на той же странице, как показано здесь
второй код, который я пробовал в библиотекеBSIX, но я думаю, что окно слишком маленькое
UI:
ui = fluidPage(
theme = shinytheme("cerulean"),
mainPanel(
div(align = "center", style="margin-left:500px",
radioButtons("typeInput", "Extract tweets by: ",list("Hashtag" = "hashtag", "Twitter Username"= "username"),inline=T),
textInput("hashtagInput", "Enter search string","", placeholder = "input search string"),
conditionalPanel(
condition = "input.typeInput == 'username'",
textInput("usernameInput", "Username", placeholder = "input username")),
sliderInput("numberInput", "Select number of tweets",min = 0, max = 3000, value = 100),
br(),
actionButton("goButton", "Search", icon("twitter"),
style="color: #fff; background-color: #337ab7"),
bsModal("modalExample", "Your result", "goButton", size = "large",dataTableOutput("tweetTable"))
)))
сервер:
server = function(input, output)
{
data = eventReactive(input$goButton, {
if (input$typeInput == "hashtag")
{
tweetOutput = searchThis(search_string = input$hashtagInput,
number.of.tweets = input$numberInput)
}
else if (input$typeInput == "username")
{
tweetOutput = userTL(user.name = input$usernameInput,number.of.tweets = input$numberInput)
}
else {}
library(twitteR)
df.tweets = data.frame(tweetOutput)
tweetOutput = df.tweets
})
output$tweetTable =renderDataTable({data()}, options = list(lengthMenu = c(10, 30, 50), pageLength = 5))
}
как показано здесь:
и вот функция поиска, которую я вызвал:
searchThis = function(search_string,number.of.tweets = 100)
{
search_tweets(search_string,n = number.of.tweets, lang = "en")
}
userTL = function(user.name,number.of.tweets = 100)
{
userTimeline(user.name,n = number.of.tweets)
}
Есть ли другой способ сделать это?спасибо