我在Shiny R中有一個應用程序。在ui.R我讀取了Textinput,在global.R我使用sqldf()處理查詢。如何讀取ui.R中的TextInput,在global.R中處理具有此值的查詢並使用Shiny在服務器中顯示
如何在Global.R中讀取ui.R的Textinput?
ui.R
shinyUI(fluidPage(
#books <<- list("Descritores FOUSP" = "descritor"),
# Application title
titlePanel("CRAI"),
headerPanel(title="Pesquisa de Descritores"),
sidebarLayout(
sidebarPanel(
h5('Qual é o tema da sua pesquisa ?'),
textInput("descritor", "Digite um descritor",""),
submitButton('Pesquisar')
)
)
這爲textInput名稱爲 「descritor」,我想在查詢中使用的global.R
我嘗試這樣做:
output$desc <- renderText({
paste(input$descritor)})
sql <- sprintf("SELECT * FROM csv WHERE Assuntos = '%s'", output$desc)
但我做不到在global.R上閱讀「descritor」。
在全局中沒有定義輸入/輸出對象。你需要這個服務器功能。您可以將參數從輸入傳遞到全局函數,但不能直接從'input'中讀取。最好有一個更完整的[可重現的例子](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example),它也顯示你的服務器代碼。 – MrFlick