我想在运行时将checkboxinput值更改为FALSE / TRUE。我该怎么办?
checkboxInput(inputId = "smoother", label = "Overlay smooth trend line", value = FALSE)
答案 0 :(得分:1)
您可以使用updateCheckboxInput()
。请参见下面的示例:
可复制的示例:
library(shiny)
ui <- fluidPage(
actionButton(
inputId = "check",
label = "update checkbox"
),
checkboxInput(
inputId = "checkbox",
label = "Input checkbox"
)
)
server <- function(input, output, session) {
observeEvent(
eventExpr = input$check, {
updatedValue = !input$checkbox
updateCheckboxInput(
session = session,
inputId = "checkbox",
value = updatedValue
)
}
)
}
shinyApp(ui, server)