gpt4 book ai didi

r - valueBox shinydashboard/shiny 中的货币符号

转载 作者:行者123 更新时间:2023-12-01 13:49:20 28 4
gpt4 key购买 nike

我创建了一个在 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 代码( 甚至 ),如下所示。你也可以使用 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)

关于r - valueBox shinydashboard/shiny 中的货币符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33145029/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com