Is there a way of passing a colour object in to a valuebox()
using shiny modules?
This works without the colour argument, but does not work with it.
color = uiOutput(ns("colour")), # this does not work !!!!!
library(shiny)
library(shinydashboard)
# values -----------------------------------------------------------------
label1 <- "rows"
icon1 <- icon("calendar")
colour1 <- "blue"
# infobox module ----------------------------------------------------------
info_stat_ui <- function(id){
ns <- NS(id) # define namespace for below
valueBox(uiOutput(ns("num")),
uiOutput(ns("label")),
icon = uiOutput(ns("icon")),
color = uiOutput(ns("colour")), # this does not work !!!!!
# color = "blue", # but using this does work
width = 4)
}
info_stat_server <- function(id, dataset, label, icon, colour){
moduleServer(id, function(input, output, session){
# the label of the valuebox
output$label <- renderUI(paste0(label))
# the icon of the valuebox
output$icon <- renderUI(icon)
# the colour of the valuebox
output$colour <- renderUI(colour)
# the value
output$num <- renderUI({
paste(
nrow(dataset)
)
})
})
}
# the app -----------------------------------------------------------------
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
info_stat_ui("test")
)
)
)
server <- function(input, output) {
info_stat_server("test",
dataset = iris,
label = label1,
icon = icon1,
colour = colour1
)
}
shinyApp(ui, server)
It produces this error:
Error during wrapup: Invalid color:
. Valid colors are: red, yellow, aqua, blue, light-blue, green, navy, teal, olive, lime, orange, fuchsia, purple, maroon, black.
Error: no more error handlers available (recursive errors?); invoking 'abort' restart