【问题标题】:calling reactive function with data to render UI使用数据调用反应函数来呈现 UI
【发布时间】:2017-06-15 20:09:21
【问题描述】:

我有以下数据集。我想选择汽车品牌,它应该在下一个选择中自动更新该品牌的相应车型 比如说数据集如下

dataset.csv  KIA         Ford
            Sportage   Mustang
            sorento      Explorer

代码:

server <- function(input, output) {   
    abc<-reactive({
        abc <- fread("dataset.csv")
    })
    output$choose_brand<-renderUI({
        selectInput("brand","brand",names(abc()))
    })
    output$choose_model<-renderUI({
        # the error is here.how can I call dataset 
        # abc and select a column from that dataset
        selectInput("model","model",a()$input$brand)
    })
}

【问题讨论】:

    标签: r shiny reactive-programming


    【解决方案1】:

    试试

    selectInput("model","model",abc()[input$brand])
    

    你不能把变量放在$的右边,用[]代替。

    【讨论】:

      猜你喜欢
      • 2021-10-02
      • 1970-01-01
      • 2021-12-10
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      • 2021-03-18
      • 2018-06-23
      • 1970-01-01
      相关资源
      最近更新 更多