lundi 17 décembre 2018

Interactive valueBox in R Shiny Dashboard

I am trying to create a value box that displays the average sales from an uploaded excel file, so the data (newdata()) is reactive. Right now I have the following code, however I get this error when I try to run it: "no applicable method for 'filter_' applied to an object of class "c('double', 'numeric')"".

output$productivityBox1 <- renderValueBox({

  if(input$timeView == 'Monthly'){
      return(average_sale = filter(newdata()$Bookings,yr == input$yearOption1 & mo == input$month1))
    }

  if(input$timeView == 'Quarterly'){
      return(average_sale = filter(newdata()$Bookings,yr == input$yearOption1 & qrt == input$quarter1))
    }

  else{
      return(average_sale = filter(newdata()$Bookings,yr == input$yearOption1))
    }

  valueBox(value= formatC(average_book, digits = 2, format = "f"),
           subtitle = "Average Productivity:",
           icon = icon("money-bill-wave", lib = "font-awesome"),
           color = "red")
})

I would like the average sales number to change as the filters on the data are edited. Any help is greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire