货币符号在valueBox shinydashboard /有光泽

时间:2015-10-15 09:39:12

标签: r shiny shinydashboard

我创建了一个在值框中显示值的闪亮应用。这些值应该与相应的货币($或€或£)一起显示,但是,只显示$ -sign。

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)

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

您好,您可以使用以下的€(&#8364;甚至&euro;)HTML代码。您还可以使用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)