下面的代码创建了一个绘图,并使用精彩的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")
答案 0 :(得分:0)
解决方案,由包工作者提供给记者包google小组:
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")