Reputation: 373
I want to display value box in my shiny dashboard using flexdashboard package. Please check my code, the value box is not getting displayed. Please help me on this issue.
UI Code
library(shiny)
library(shinydashboard)
library(flexdashboard)
ui <- dashboardPage(skin = "black",
dashboardHeader(title = "test"),
dashboardSidebar(
sidebarMenu()),
dashboardBody(
fluidRow(
valueBoxOutput("vbox1", width = 2),
valueBoxOutput("vbox2", width = 2),
valueBoxOutput("vbox3", width = 2),
valueBoxOutput("vbox4", width = 2),
valueBoxOutput("vbox5", width = 2),
valueBoxOutput("vbox6", width = 2))))
Server code
server <- function(input, output) {
#valuebox
output$vbox1 <- renderValueBox({
d <- 10
valueBox( d, caption = "Coss")
})
output$vbox2 <- renderValueBox({
d <- 42
valueBox( d,"Ccy")
})
output$vbox3 <- renderValueBox({
d <- 75
valueBox( d,"Cty")})
output$vbox4 <- renderValueBox({
d <- 21
valueBox( d,"Dup")})
output$vbox5 <- renderValueBox({
d <- 34
valueBox( d,"Inte")})
output$vbox6 <- renderValueBox({
d <- 56
valueBox( d,"Acd")})
}
shinyApp(ui, server)
I am getting only the text but not the valuebox.
Thanks Balaji
Upvotes: 2
Views: 6914
Reputation: 192
a.lay is almost correct. You need the namespace for the server functions as well...
shinydashboard::valueBoxOutput('valueBoxA')
output$valueBoxA <- shinydashboard::renderValueBox({
shinydashboard::valueBox(
'Default',
x
)
})
Upvotes: 6
Reputation: 161
flexdashboard package masks valueBoxOutput() which is a function of the shinydashboard package. So to fix this you should use shinydashboard::valueBoxOutput
instead of valueBoxOutput
Upvotes: 6
Reputation: 48
Your arguments are the wrong way round in valueBox in the server. The MWE below works for me:
library(shiny)
library(shinydashboard)
library(flexdashboard)
ui <- dashboardPage(skin = "black",
dashboardHeader(title = "test"),
dashboardSidebar(
sidebarMenu()),
dashboardBody(
fluidRow(
valueBoxOutput("vbox1", width = 2),
valueBoxOutput("vbox2", width = 2))))
server <- function(input, output) {
#valuebox
output$vbox1 <- renderValueBox({
d <- 10
valueBox( "Coss", d)
})
output$vbox2 <- renderValueBox({
d <- 42
valueBox("Ccy", d)
})
}
shinyApp(ui, server)
Upvotes: 3