目前我在自己的shinydashboard工作。我想请你帮忙。我想在输入框中显示与Data_Location()$Address
对应的Data_Location()$Location_skey
。通常你可以这样做:
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="")
我想感谢你阅读这篇文章,如果你能帮助我,我会很高兴。
谢谢!
答案 0 :(得分:4)
我认为这就是你想要的:
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)
得到以下特性: