I have a shiny app where I would like to get the change in a select input compared to the last selection.
For example in this app, three months are initially selected. January February March
If a user selects April, I would like to see the change between the initial selection and the current selection.
**Initial selection:**
January February March
**Current selection:**
January February March April
library(shiny)
library(shinydashboard)
library(htmltools)
ui <- fluidPage(
inputPanel(
selectInput("months", label = "Select Months",
choices = c(month.name[]), selected = month.name[1:3],
multiple = TRUE)),
strong("Initial selection:"), textOutput("initial_selection"), br(),
strong("Current selection:"), textOutput("current_selection")
)
server <- function(input, output) {
## Initial selection (should stay the same for one additional change)
output$initial_selection <- renderText({ input$months })
## Current selection (after the change)
output$current_selection <- renderText({ input$months })
}
shinyApp(ui, server)
I tried a few random methods but with no success. Any help will be much appreciated.
Cheers,
