mardi 11 mai 2021

After select some checkboxes, make some tests and disply the output: R shiny

The basic question (which I think is very easy, but I can't get to it): I have a Shiny app which allows you to upload an excel file, then set some variables. I want to create 3 checkboxes with 3 tests and then, after selecting the first test (for e.g.) to select the checkboxes of which variable to make the test, and after, the output of the tests:

Something like this (which I already have done):

I have tried something like this:

  output$Stattest = renderUI({
     checkboxGroupInput("Stattest", "Choose test for stationarity", choices = c("ADF","PP","KPSS-TREND"))
  })
  
  
  output$varSTAT = renderUI({
    if (is.null(datos())){
      return(NULL)}
    variables = colnames(datos())
    div(class = "row-fluid",
        
        div(class="span1",checkboxGroupInput("Var", strong("Variables for stationarity test",style = "color:green"), variables)),
    )
  })
  
  adf <- reactive({


    if(input$Stattest == "ADF"){
   
     
      adf.test(df_sel()[[input$Var]])
    
     
    }})

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

The code from above prints only one output (just for one variable) and if I select another variable, the error is: subset2: attempt to select less than one element in integerOneIndex. I think to use some with lapply but I don't know exactly how.

I have tried also:

 adf <- reactive({


    if(input$Stattest == "ADF"){
   
     for(i in length(input$Var))
      adf.test(datos()[[input$Var[[i]]]])
    
     
    }})


But...I do not know how to print the outputs.

The "major" problem is that I need to have a reactive function, because this outputs would be listed in a report (Rnw). Thanks in advance! :) :D




Aucun commentaire:

Enregistrer un commentaire