Shiny Tutorial Error in R

后端 未结 2 734
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 16:16

I\'ve seen some cool uses of shiny with R to make web applications and wanted to try to learn how to use it myself. I am doing the tutorial right now, but when I get to the

相关标签:
2条回答
  • 2020-12-06 16:51

    For me, I had this issue when I forgot about using renderPrint, which is easy to forget when you're just starting up.

    For example:

    shinyServer(function(input,output) {
      output$outputString <- input$something
      }
    )
    

    When what I really needed to do was

    shinyServer(function(input,output) {
      output$outputString <- renderPrint({input$something})
      }
    )
    
    0 讨论(0)
  • 2020-12-06 16:54

    I know this question is a bit dated, but responding for those who might come searching when faced with the same error message.

    Since you haven't included your code, let's look at why this error message happens in general.

    When the error message says "Operation not allowed without an active reactive context." what it is saying is that you are accessing a "reactive" element inside the ShinyServer function, but outside any of the reactive functions such as renderTable or renderPlot() etc.

    This won't work inside ShinyServer()

    shinyServer(function(input, output) {
        abc <- input$some.input.option   
    
      #other reactives here
    
    })
    

    Fix: Wrap it inside a reactive

    This will work:

    shinyServer(function(input, output) {
      abc <- reactive({
       abc <- input$some.input.option    
      })
    
      #other reactives here
    
    })
    

    And now, from inside the ShinyServer function, you can access that Input parameter by calling abc() Note the parenthesis since it is a reactive function.

    Hope that helps.

    0 讨论(0)
提交回复
热议问题