I saw the following code here on StackOverflow.
(我在StackOverflow上看到了以下代码。)
When you enter values into X and Y, the sum is calculated, and the message "X + Y = " is displayed. (在X和Y中输入值时,将计算总和,并显示消息“ X + Y =”。)
However, when you reset, the "X + Y = " message still appears from the previous example. (但是,当您重置时,上一示例仍显示“ X + Y =”消息。)
How can I clear that message, please? (请问如何清除该信息?)
Here is the code:
(这是代码:)
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
div(id="form",
sidebarLayout(
sidebarPanel(
numericInput("x","X",0),
numericInput("y","Y",0)
),
mainPanel(
br(),
column(width=6,actionButton("calc", "Calculate")),
column(width=6,actionButton("reset", "Reset")),
br(),br(),br(),
textOutput("sum"))
)
))
# Define the server logic
server <- function(input, output) {
output$sum <- renderText({
req(input$calc)
isolate(paste("X + Y =", input$x + input$y))
})
observeEvent(input$reset, {
reset("form")
})
}
# Run the application
shinyApp(ui = ui, server = server)
ask by user1544953 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…