下面的代码使用出色的 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")