【问题标题】:Shiny selectInput from column DF来自列 DF 的闪亮 selectInput
【发布时间】:2016-10-08 12:25:58
【问题描述】:

目前我正在开发自己的闪亮仪表板。我想请你帮忙。我想在与Data_Location()$Location_skey 对应的输入框中显示Data_Location()$Address。通常你可以这样做:

selectInput("KPI", "Choose a KPI:", choices = c("Aantal Sessies Aansluiting"="AantalSessiesAansluiting",
                                                                               "Aantal Unieke RFIDS Aansluitingg"="AantalUniekeRFIDsAansluiting",
                                                                               "Beschikbare Dagen Aansluiting"="BeschikbareDagenAansluiting",selected="")

不同的是我要使用数据框列。

head(Data_Location()$Location_skey)
[1] -1  
[2]  1  
[3]  2  
[4]  3  
[5]  4 

head(Data_Location()$Address)
[1] onbekend
[2] Putstraat 86
[3] 1e De Riemerstraat 1   
[4] Van Spaenstraat 23     
[5] Suze Groeneweglaan 323 

selectInput("location", "Selected a charge point",choices =c("",Data_Location()$Location_skey), selected="")

感谢您阅读这篇文章,如果您能帮助我,我将非常高兴。

谢谢!

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    我想这就是你想要的:

    library(shiny)
    
    ui <- fluidPage(
        selectInput("sip","select",choices=1:3)
    ) 
    
    server <- function(input,output,session){
      df <- data.frame(cnames=c("a","b","c"),keys=c(1,2,3))
      chlst <- df$keys
      names(chlst) <- df$cnames
      updateSelectInput(session,"sip",label="label",choices=chlst)
    } 
    shinyApp(ui,server)
    

    屈服:

    【讨论】:

      猜你喜欢
      • 2018-04-20
      • 2019-03-18
      • 2018-09-21
      • 2019-03-20
      • 2019-01-24
      • 2015-05-07
      • 1970-01-01
      • 2015-08-03
      • 2017-02-25
      相关资源
      最近更新 更多