0
selectInputを '書き込み可能'に変更したいです。たとえば、 'location'にはアムステルダム、ロッテルダム、デンハーグなどがあります。私は '書き込み可能'なinputselectorを実装したいと思います。だから誰かが "Ams .."や "Amster ..."と書いたときに、この基準に合致する可能性のある場所が表示されます。 誰か助けてくれますか?前もって感謝します。書き込み可能なselectInputセレクタ
これは私の単純化されたUIセクションです:
library(DT)
library(shiny)
library(shinydashboard)
Location = c("Amsterdam","Amsterdam","Amsterdam","Rotterdam","Rotterdam","Rotterdam","Den Haag","Den Haag","Den Haag")
Year = c(2015,2014,2016,2015,2016,2016,2017,2016,2014)
Person = c("John", "Ann", "Katy", "Ann", "Katy", "William", "Henry", "Luke", "Luke")
mockup = data.frame(Location, Year, Person)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(
sidebarMenu(
menuItem("Selection", tabName = "selection")
)
),
dashboardBody(
tabItems(
tabItem(tabName = "selection",
fluidRow(
box(width = 5,
title = "TITLE", "Choose something",
collapsible = FALSE,
htmlOutput("Location_selector"),
htmlOutput("Year_selector")
),
mainPanel(
DT::dataTableOutput("selection")
)
))
)
)
)
と、これは私のサーバーセクションです:
server <- function(input, output, session) {
output$Location_selector = renderUI({
selectInput(inputId = "Location",
label = "Location:",
choices = sort(as.character(unique(mockup$Location))))
})
output$Year_selector = renderUI({
data_available = mockup[mockup$Location == input$Location, "Year"]
selectInput(inputId = "Year",
label = "Year:",
choices = sort(unique(data_available)),
selected = unique(data_available)[1])
})
}
shinyApp(ui, server)