3

我创建了一个在 valueBox 中显示值的闪亮应用程序。这些值应该以相应的货币($ 或 € 或 £)显示,但是,仅显示 $ 符号。

MWE 如下所示:

library(shinydashboard)
library(shiny)

ui <- dashboardPage(
  dashboardHeader(title = "MWE"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      valueBox(value = paste0(sprintf("%.2f", 123.14), "$"), 
               subtitle = "This works good:", 
               color = "green"),
      valueBox(value = paste0(sprintf("%.2f", 123.14), "€"), 
               subtitle = "This does not work:", 
               color = "red")
    )
  )
)
server <- function(input, output) {
}

shinyApp(ui, server)

有任何想法吗?

4

1 回答 1

4

嗨,您可以使用 HTML 代码来表示 €(&#8364;甚至&euro;),如下所示。你也可以使用FontAwesome 图标

library(shinydashboard)
library(shiny)

ui <- dashboardPage(
  dashboardHeader(title = "MWE"),
  dashboardSidebar(),
  dashboardBody(
    fluidRow(
      valueBox(value = paste0(sprintf("%.2f", 123.14), "$"), icon = icon("dollar"),
               subtitle = "This works good:", 
               color = "green"),
      valueBox(value = HTML(paste0(sprintf("%.2f", 123.14), "&#8364;")), icon = icon("euro"),
               subtitle = "This does not work:", 
               color = "red")
    )
  )
)
server <- function(input, output) {
}

shinyApp(ui, server)
于 2015-10-15T09:46:09.403 回答