【问题标题】:Input ID in Shiny selectInput() not refreshing the resultsShiny selectInput() 中的输入 ID 不刷新结果
【发布时间】:2013-12-30 07:01:25
【问题描述】:

我正在尝试提供组织名称作为 ui.R 中的输入,如下所示 -

selectInput("Organization", "Enter an Org:", choices = c("Blenheim Palace", "Chatsworth", "Gloucester Cathedral", "Manchester Cathedral", "Royal Albert Hall", "StPauls Cathedral"))

我尝试使用此输入来刷新我的 wordcloud。基本上,当我选择一个组织时,比如 Blenheim Palace,wordcloud 应该会随着来自 tripadvisor.com 的该组织的 cmets 而改变。 我的server.R 代码如下 -

OrganizationInput <- reactive({switch(input$Organization, "Blenheim Palace" = Blenheim_Palace, "Chatsworth" = Chatsworth, "Gloucester Cathedral" = Gloucester_Cathedral, "Manchester Cathedral" = Manchester_Cathedral, "Royal Albert Hall" = Royal_Albert_Hall, "StPauls Cathedral" = StPauls_Cathedral)}) 

rawData <- reactive(function(){
    some_txt <- sqlQuery(dbhandle, 'SELECT REVIEW_COMMENTS FROM XXXXXX.tripadvisor_data where brand_name = "OrganizationInput()"')
    some_txt <- data.frame(some_txt)

我尝试使用rawData() 作为 wordcloud 的输入。但我收到以下错误 - Error: invalid 'cex' value,如果我在 rawData 中给出个人名称(比如布伦海姆宫),它可以工作。 任何帮助/澄清将不胜感激。

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    如果你想让OrganizationInput成为一个字符串,你需要在switch a la中引用值吗:

    OrganizationInput <- reactive({switch(input$Organization, "Blenheim Palace" = "Blenheim_Palace", "Chatsworth" = "Chatsworth", ...
    

    否则,您会尝试引用名为 Blenheim_Palace 的变量,该变量可能不存在,对吧?

    【讨论】:

      【解决方案2】:

      本质上是在 sqlQuery() 中参数化 input$Organization 的问题。我使用了来自

      的想法

      R Shiny error 'closure' not subsettable

      它奏效了。感谢您调查我的问题。

      【讨论】:

        猜你喜欢
        • 2018-07-15
        • 1970-01-01
        • 2019-12-21
        • 1970-01-01
        • 2023-04-02
        • 2021-11-03
        • 2022-10-14
        • 2012-09-06
        • 1970-01-01
        相关资源
        最近更新 更多