Можно управлять brushOpts в plotOutput через ввод в пользовательском интерфейсе (например, radioButtons).Я пишу простой код здесь.Идея состоит в том, что когда radioButtons равен "sweeping"
, я хочу установить resetOnNew в brushOpts равным TRUE
, а если radioButtons равен "brushing"
, я хочу установить resetOnNew будет FALSE
.
library(shiny)
ui <- fluidPage(
radioButtons("select", "Select type:",
choices = c("sweeping", "brushing"),
selected = "sweeping"),
plotOutput(outputId="plots",
brush = brushOpts(id = "plot_brush",
resetOnNew = TRUE))
)
server <- function(input, output, session) {
output$plots <- renderPlot({
input$plot_brush
if(input$select == "sweeping") {
plot(1:10)
} else {
# input select is "brushing", I want to update
# resetOnNew in brushOpts to FALSE, like:
# brushOpts(id = "plot_brush",
# resetOnNew = FALSE)
plot(10:1)
}
})
}
shinyApp(ui, server)