Reactive variables in Shiny for later calculations

前端 未结 2 2020
無奈伤痛
無奈伤痛 2021-01-15 02:15

Total novice here.

I have an output that writes the result of a formula, with variables based on inputs

output$text_calc <- renderText({
    paste         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-15 02:59

    If you want to reuse this formula elsewhere, to avoid recalculating it :

    server <- shinyServer(function(input, output,session){
    
      formula <- reactive({
        W <- input$num_W
        L <- input$num_l
        A <- input$slider_a
        W*L-A
      })
    
    
      output$text_calc <- renderText({
        paste("The result is =", formula())
      })
    
    
    })
    

提交回复
热议问题