Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

shiny - 在R Shiny中推送重置时如何清除“隔离”变量(How to clear an “isolate” variable when reset is pushed in R Shiny)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...