下面的代码创建了一个图表,并使用出色的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")
解决方案,由程序包作者在reporters-package google组上提供:
https://groups.google.com/forum/!主题/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")