简体   繁体   English

DF列中的闪亮selectInput

[英]Shiny selectInput from column DF

Currently i am working on my own shinydashboard. 目前,我正在开发自己的Shinydashboard。 And i would like to ask you for help. 我想向您寻求帮助。 I would like to show Data_Location()$Address in my inputbox that is corresponding to Data_Location()$Location_skey . 我想在我的Data_Location()$Address显示与Data_Location()$Location_skey对应的Data_Location()$Address Normally you can do it like this: 通常,您可以这样做:

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

The difference is that I want to use a dataframe column. 区别在于我要使用数据框列。

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="")

I would like to thank you for reading this post and I would be very pleased if you could help me out. 非常感谢您阅读这篇文章,如果您能帮助我,我将非常高兴。

Thanks! 谢谢!

I think this is what you want: 我认为这是您想要的:

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)

yielding: 收益:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM