从 r markdown 文件运行此代码时:
---
output: pdf_document
---
```{r test}
library(extrafont)
library(waffle)
parts <- c(80, 30, 20, 10)
waffle(parts, rows=8, use_glyph="shield")
```
我收到以下警告,类似于:
## Warning: Removed 4 rows containing missing values (geom_text).
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : conversion failure on 'ï„2' in 'mbcsToSbcs': dot substituted for <ef>
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x
## $y, : conversion failure on 'ï„2' in 'mbcsToSbcs': dot substituted for <84>
我尝试了几件事,例如:
- 使用latex fontawesome 包。
- 在此处运行示例:Compile RMarkdown PDF with Waffle Chart and Glyphs FAILURE。包括 MWE(我遇到了quartz_pdf 的问题,可能变成我在 Windows 上?)
- 使用 fontawesome、emojifont 和 emo r 包
请注意,在输出 HTML 文件时会正确呈现字形。仅在控制台中调用 waffle 代码时,它们也会正确呈现。
我什至可以通过 Latex fontawesome 包直接渲染 fontawesome 符号,方法是输入诸如\faAmazon
我今天大部分时间都在试图解决这个问题(此时 100% 的沉没成本谬误)。
编辑:仅供参考,以防其他人遇到此问题。我将图表渲染为 .png,作为临时文件并调用图像。仍在寻找正确的方法来做到这一点,因为我认为我会在此过程中失去一些图像质量。