mercredi 23 juin 2021

R Shiny: Displays all tests at once after checking the checkboxes

I am trying to make a R Shiny App, which will print 3 statistical tests simultaneous, after the checkboxes were selected. The problem is the app is printing just one output, and the other ones "are not founded".Like can be seen here

I tried with

if(input$Stattest=='PP' | input$Stattest==1)

but..it doesn't work.

My code is:

 output$Stattest = renderUI({
     checkboxGroupInput("Stattest", "Choose test for stationarity", choices = c("ADF","PP","KPSS-TREND"))
  })
adf <- reactive({
    if(is.na(input$Stattest)){
      return(NULL)}

     if(input$Stattest=='ADF'){
       d=list()
       c=list(df_sel()[[print(input$y)]],df_sel()[[print(input$x1)]],df_sel()[[print(input$x2)]])
       for (i in 1:3){
         d[[i]]=adf.test(c[[i]])
       }
           }
    d
    })

  output$ADF=renderPrint({
    adf()
  })

 pp <- reactive({

    if(is.na(input$Stattest)){
      return(NULL)}

    if(input$Stattest=='PP' | input$Stattest==1){
      ptest=list()
      d=list(df_sel()[[print(input$y)]],df_sel()[[print(input$x1)]],df_sel()[[print(input$x2)]])
      for (i in 1:3){
        ptest[[i]]=pp.test(d[[i]])
      }

    }
    ptest
  })


  output$PP=renderPrint({
    pp()
  })

The main "problem" is that I need to create this reactive functions, because all of these tests will be printed in a pdf-report. Any idea how could I make it work?

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire