Here is a solution using basic shiny:
library(shiny)
ui <- fluidPage(
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins1",
"Number of bins 1:",
min = 1,
max = 50,
value = 30),
sliderInput("bins2",
"Number of bins 2:",
min = 1,
max = 50,
value = 30),
textOutput("printChangedInputs")
),
mainPanel(
plotOutput("distPlot1"),
plotOutput("distPlot2")
)
)
)
server <- function(input, output) {
output$distPlot1 <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins1 + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$distPlot2 <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins2 + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
previousInputStatus <- NULL
changedInputs <- reactive({
currentInputStatus <- unlist(reactiveValuesToList(input))
if(is.null(previousInputStatus)){
previousInputStatus <<- currentInputStatus
changedInputs <- NULL
} else {
changedInputs <- names(previousInputStatus)[previousInputStatus != currentInputStatus]
print(paste("Changed inputs:", changedInputs))
previousInputStatus <<- currentInputStatus
}
return(changedInputs)
})
output$printChangedInputs <- renderText({paste("Changed inputs:", changedInputs())})
}
shinyApp(ui = ui, server = server)
Edit: Another way would be to listen for the JavaScript event shiny:inputchanged
:
library(shiny)
ui <- fluidPage(
tags$head(
tags$script(
"$(document).on('shiny:inputchanged', function(event) {
if (event.name != 'changed') {
Shiny.setInputValue('changed', event.name);
}
});"
)
),
titlePanel("Old Faithful Geyser Data"),
sidebarLayout(
sidebarPanel(
sliderInput("bins1",
"Number of bins 1:",
min = 1,
max = 50,
value = 30),
sliderInput("bins2",
"Number of bins 2:",
min = 1,
max = 50,
value = 30),
textOutput("changedInputs")
),
mainPanel(
plotOutput("distPlot1"),
plotOutput("distPlot2")
)
)
)
server <- function(input, output) {
output$distPlot1 <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins1 + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$distPlot2 <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins2 + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$changedInputs <- renderText({paste("Changed inputs:", input$changed)})
}
shinyApp(ui = ui, server = server)
Please see this for more information.