R 在确认删除后更新列表框

R 在确认删除后更新列表框,r,shiny,R,Shiny,这可能是关于shiny 我有一个下拉列表,用户点击一个按钮,下拉菜单应该更新为少一个项目 这里是一个玩具的例子 library(shiny) library(shinythemes) getData<- function() { data <- c('A','B','C','D') return (data) } ui <- fluidPage( selectInput("names", "Select Data", getData(), multi

这可能是关于
shiny
我有一个下拉列表,用户点击一个按钮,下拉菜单应该更新为少一个项目

这里是一个玩具的例子

library(shiny)
library(shinythemes)

getData<- function()
{
  data <- c('A','B','C','D')
  return (data)
}   



ui <- fluidPage(

  selectInput("names", "Select Data", getData(), multiple = FALSE),
  actionButton("del","delete"),
  bsModal("modalnew", "Approve Data For Reporting", "del", size = "medium",
          HTML("Note: Confirm Deletion"),
          br(),br(),
          actionButton("delyes", "Yes"),
          actionButton("delno", "No")
  )

)

server <- function(input, output, session) {

  # Reactive part that gets the data and populates the drop down
  my_sel = reactive({
    mydata = getData()
  })

  # Confirmation Menu to Approve the upload
  observeEvent(input$delyes, {
    toggleModal(session, "modalnew", toggle = "close")

# Delete an Item, Update the list box with one less item


  })

}

shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(shinythemes)

getData使用reactiveValues和updateSelectInput更改选择输入

server <- function(input, output, session) {

# Reactive part that gets the data and populates the drop down
v <- reactiveValues(
    mydata = getData()
)

# Confirmation Menu to Approve the upload
observeEvent(input$delyes, {
    toggleModal(session, "modalnew", toggle = "close")

    # Delete an Item, Update the list box with one less item
    v$mydata <- v$mydata[!v$mydata %in% input$names]

    #update the selection
    updateSelectInput(session, "names",
                      choices = v$mydata
    )

})   
}

服务器谢谢@Icaro Bombonato,我不知道这是一个选项