【问题标题】:Plotting Euro Symbol € in ggplot2?在ggplot2中绘制欧元符号€?
【发布时间】:2011-10-06 01:56:00
【问题描述】:

欧元符号 在 PDF 输出中显示为 ...

ggplot() + theme_bw() + geom_line() + scale_y_continuous(formatter = "euro")

【问题讨论】:

    标签: r ggplot2 euro


    【解决方案1】:

    启动PDF图形时使用ISOLatin9.enc编码

    pdf(encoding = "ISOLatin9.enc")
    

    http://stat.ethz.ch/R-manual/R-patched/library/graphics/html/text.html 表示欧元符号可以选择以欧元为字符的 ISO-8895-15 (Latin-9)

    【讨论】:

      【解决方案2】:

      以下是 3 种将数字格式化为“EU”格式的方法:

       # 1. Method 1
       library(scales)
       euro <- dollar_format(prefix = "\u20ac", big.mark = ",")
       euro(20)
      
       # 2. Method 2
       library(formattable)
       currency(20, symbol = "\U20AC", digits = 0)
      
       # 3. Method 3
      
       # 3.1. Load package
       library(DT)
      
       # 3.2. Create data set
       m = cbind(matrix(rnorm(120, 1e5, 1e6), 40), runif(40), rnorm(40, 100))
       colnames(m) = head(LETTERS, ncol(m))
       m
      
       # 3.3. Format the columns 'A' (euro), 'C' (usd), and 'D' (percentages)
       datatable(m) %>% 
         formatCurrency(c('A'), '\U20AC', digits = 0) %>% 
         formatCurrency(c('C')) %>% 
         formatPercentage('D', 2)
      

      希望其中一个有用。

      【讨论】:

        猜你喜欢
        • 2010-11-26
        • 2014-11-11
        • 2012-05-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-14
        • 1970-01-01
        相关资源
        最近更新 更多