在ggplot2中绘制欧元符号€?

5
欧元符号 在 PDF 输出中显示为 ...
ggplot() + theme_bw() + geom_line() + scale_y_continuous(formatter = "euro")
2个回答

7

2

以下是三种将数字格式化为“欧洲”格式的方法:

 # 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)

希望其中之一能够有所帮助。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接