Multiple input variables in shiny server

Hello,
I want to update my output according to 3 different input variables, but the output is just updated by "var". I know that I should update the data <- reactive({}) function for "var", "Group", and "Timepoint", but I need help! I tried multiple ways but non of them worked!
Thanks for your support in advance.

> head(metab)
  Replicate Group Timepoint        M0       M1     M2 M3 M4
1         1  DM         0   462276966 18832499 123172  0  0
2         2  DM         0   389073706 16540080 104004  0  0
3         3  DM         0   440497937 18778082  74654  0  0
4         4  DM         0   339266538 14427218  89319  0  0
5         5  DM         0   476276612 20352483  51748  0  0
6         6  DM         0   392164060 16587310 111081  0  0

library(shiny)

metab<- read.csv("metab.csv")
metab[,c("M0","M1","M2","M3","M4")] <- sapply(metab[,c("M0","M1","M2","M3","M4")],as.numeric)

ui <- fluidPage(
  
  titlePanel("weight Expectation"),
      
      selectInput("var",label="Choose an ...",choice=c("M0"=4,
                                                                "M1"=5,
                                                                "M2"=6,
                                                                "M3"=7,
                                                                "M4"=8), selectize=FALSE),
    
    selectInput(inputId = "Group", label = strong("Group"),
                choices = unique(metab$Group),
                selected = "DM"),
    
    
    selectInput(inputId = "Timepoint", label = strong("Timepoint"),
                choices = unique(metab$Timepoint),
                selected = 30),
    
  
      verbatimTextOutput("statistic"),
      plotOutput("box")
)


server <- function(input,output){

  data <- reactive({
   metab[,as.numeric(input$var)]
    
  })

    
  output$statistic <- renderPrint({
    summary(data())
  })
  
  output$box <- renderPlot({
    x<-summary(data())
    boxplot(x,col="sky blue",border="purple")
  })
}

shinyApp(ui = ui, server = server)

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.