1
我開發了一個帶有RStudio的Shiny應用程序,它接受輸入,執行查找表的搜索,然後返回一個值。在用戶點擊提交按鈕之前,不應該執行搜索。但是,啓動後,應用會自動執行並返回查找表中的第一組值。在初次搜索後,該應用程序完全按照預期工作。是否可以抑制這個初始搜索(或者有一個默認值),並且在按下提交按鈕時只進行搜索?我可以不存在重複性的代碼,但這裏是我的輸入(server.R)和我的用戶界面(ui.R)代碼的結構:閃亮的應用程序 - 如何在啓動時抑制功能和渲染?
#server.R snippet
output$Word <- renderText({
predictWord <- input$gram
predict.function(predictWord) #User-defined function in global.r file
})
#ui.R snippet
tabPanel("Word Prediction",
sidebarPanel(
textInput("gram", "Enter up to three words"),
submitButton("Predict")),
mainPanel(
h4("Word Prediction"),
textOutput("predictWord")))