0

下面的代码使用出色的 ReporteRs 包创建了一个绘图并将其嵌入到 Word 文档中。代码生成警告:

"argument fontname is deprecated; please usefontname_serif, fontname_sans,fontname_mono,fontname_symbol instead"

我一直无法弄清楚如何指定特定字体,例如“Times New Roman”。谢谢!

library(ReporteRs)
library(magrittr)

x <- rnorm(100); y <- (1.5 * x) + rnorm(100, 0.1)

options( "ReporteRs-fontsize" = 12 )
doc <- docx() %>%
  addPlot(function() plot(x,y, xlab = "Values of x", main="Test plot"), vector.graphic=TRUE, editable=TRUE, fontname="Times New Roman")
writeDoc( doc, file = "test.docx")
4

1 回答 1

0

包作者在记者包谷歌组上提供的解决方案:

https://groups.google.com/forum/#!topic/reporters-package/x3a_qWQ0hGc

   doc <- docx() %>%
      addPlot(function() plot(x,y, xlab = "Values of x", main="Test plot", family="serif"), vector.graphic=TRUE,
              editable=TRUE, fontname_serif = "Times New Roman")
    writeDoc( doc, file = "test.docx")
于 2016-11-09T17:06:27.737 回答