Plotting Euro Symbol € in ggplot2?

后端 未结 2 1726
伪装坚强ぢ
伪装坚强ぢ 2020-12-19 17:27

Euro Symbol is shown as ... at PDF output

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


        
相关标签:
2条回答
  • 2020-12-19 18:10

    Here are 3 methods to format numbers in "EU" format:

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

    Hope one of them can be useful.

    0 讨论(0)
  • 2020-12-19 18:13

    Use ISOLatin9.enc encoding when starting PDF graphics

    pdf(encoding = "ISOLatin9.enc")
    

    At http://stat.ethz.ch/R-manual/R-patched/library/graphics/html/text.html is said that euro symbol can selecting ISO-8895-15 (Latin-9) which has the Euro as character

    0 讨论(0)
提交回复
热议问题