shinydashboard
shinydashboard copied to clipboard
output 5 values (Characters & Numbers at the same time) in Shinydashboard
I need to present top 5 customers depending on their Collective turnover.. in R Console, I get the 5 customers one after another in 5 rows.
But on the dashboard itself, I get only the first row:
here is a screenshot of the Console: (i hided the names of the customers because this data is private)
and this is the dashboard outcome:
as you can see, it gives only the 1st customer of the top five, and without presenting its turnover in numbers
any help please?
thank you very much
As far as I am concerned valueBoxes are intended to show single values (also see here). Accordingly you would need to pass each row to the valueBox function and display them separately. I’d rather go for a bar-chart.
library(shiny)
library(shinydashboard)
library(tibble)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(uiOutput("Boxes"))
)
server <- function(input, output) {
custData <- tibble(Customer = paste0("Customer_", LETTERS[1:5]), Collective = round(runif(5, 10000, 20000)))
boxesList <- list()
for(i in seq(nrow(custData))){
boxesList[[i]] <- valueBox(value = custData$Collective[i], subtitle = custData$Customer[i], icon = icon("industry"))
}
output$Boxes <- renderUI({boxesList})
}
shinyApp(ui, server)