1

Im working in an linear regression shiny app and im having some troubles. The fisrt part is supposed to be an example with the swiss dataset. Here is the ui part:

  checkboxInput(inputId="example",
                label= "Let's see an example?",
                value=FALSE),
  conditionalPanel("input.example",
                   selectInput(inputId="swissy",
              label="Choose an response variable.",
              choices=names(swiss),
              selected=""),
  checkboxGroupInput(inputId="swissx",
                     label="Choose the explanatory variables.",
                     choices=names(swiss))
  ),

And the server part:

   observe({
    if(input$example){
      swissdata <- reactive({
      ys <- swiss[,input$swissy]
      xs <- model.matrix(~., swiss[,input$swissx])
      ms <- lm(ys~xs)
      return(ms)
      })
      output$table <- renderDataTable({swiss})
      output$model <- renderPrint({
        m0 <- swissdata()$ms
        print(summary(m0))
      })
      output$anova <- renderPrint({
        print(summary(anova(lm(swissdata()$ms))))
      })
      output$plots <- renderPlot({
        par(mfrow=c(2,2)); plot(lm(swissdata()$ms))
        ; layout(1)
      }, width=600, height=600)
    }
})

It should return, in tabsets, the summary of the linear model choosen by the user, the anova, etc. But the server is not recognizing the data, which is the dataset swiss. I dont know why this is happening,

  • Could you please make your above code reproducible? http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Shiva Dec 03 '15 at 20:11

0 Answers0