valueBox 中的货币符号 shinydashboard/shiny

Currency signs in valueBox shinydashboard/shiny

我创建了一个在 valueBox 中显示值的 shiny-app。这些值应该以相应的货币($ 或 € 或 £)显示,但是,只显示 $ 符号。

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)

有什么想法吗?

您好,您可以使用 HTML 代码兑换 €(&#8364; 甚至 &euro;),如下所示。你也可以使用 FontAwesome icons :

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)