【发布时间】:2019-06-29 21:00:40
【问题描述】:
我想在运行时将复选框输入值更改为 FALSE/TRUE。我该怎么做?
checkboxInput(inputId = "smoother", label = "Overlay smooth trend line", value = FALSE)
【问题讨论】:
我想在运行时将复选框输入值更改为 FALSE/TRUE。我该怎么做?
checkboxInput(inputId = "smoother", label = "Overlay smooth trend line", value = FALSE)
【问题讨论】:
您可以使用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)
【讨论】: